Do scala futures continue running after response in akka-http? -


i have rest service written in akka-http exposes /fire endpoint. when endpoint called service should send file, of ~50mb different service. /fire endpoint should return caller , keep sending file asynchronously, in fire-and-forget fashion.

my implementation looks this

path("fire") {   post { request: firerequest =>       complete {         sendfile(request.path)         statuscodes.ok       }     }   } }  def sendfile(path: string): future[unit] = future {   // send large file service } 

i tested , works fine.

however, when implemented similar behaviour asp.net, needed use third party framework (hangfire) handle asynchronous tasks, because threads generated completed request killed.

my question is: in akka-http sendfile guaranteed run until successful/failed completion, or there cases in thread on runs killed?

it depends on executioncontext running future against.

if using global executioncontext, behavior keep future running after request completion.

as far know, i've never seen executioncontext kill/interrupt/cancel future thread in case of request completion. concept of request completion not exist @ language level more related http layer framework, long don't use executioncontext http layer framework there's no reason have such behavior.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -