I have a REST service written in akka-http which exposes a /fire endpoint. When that endpoint is called my service should send a file, usually of ~50MB to a different service. But the /fire endpoint should return immediately to the caller and keep sending the file asynchronously, in a fire-and-forget fashion.
My implementation looks like this
path("fire") {
post { request: FireRequest =>
complete {
sendFile(request.path)
StatusCodes.OK
}
}
}
}
def sendFile(path: String): Future[Unit] = Future {
// send the large file to another service
}
I tested it and it works fine.
However, when implemented a similar behaviour with ASP.NET, I needed to use a third party framework (Hangfire) to handle the asynchronous tasks, because the threads generated by a completed request would eventually be killed.
My question is: in my akka-http sendFile is guaranteed to run until successful/failed completion, or there will be cases in which the thread on which it runs will be killed?