I am doing some Http request processing using Spray. For a request I spin up an actor and send the payload to the actor for processing and after the actor is done working on the payload, I call `context.stop(self)` on the actor to wind the actor down.The idea is to prevent oversaturation of actors on the physical machine.

This is how I have things set up..

In `httphandler.scala`, I have the route set up as follows:

```
path("users"){
   get{
      requestContext => {
         val userWorker = actorRefFactory.actorOf(Props(new UserWorker(userservice,requestContext)))
        userWorker ! getusers //get user is a case object 
      }
   }
} ~ path("users"){
     post{
       entity(as[UserInfo]){
          requestContext => {
          userInfo => {
             val userWorker = actorRefFactory.actorOf(Props(new UserWorker(userservice,requestContext)))
             userWorker ! userInfo
           }
         }
       }
     }
 }

```

My `UserWorker` actor is defined as follows:

```
trait RouteServiceActor extends Actor{
  implicit val system = context.system
  import system.dispatcher
  def processRequest[responseModel:ToResponseMarshaller](requestContex:RequestContext)(processFunc: => responseModel):Unit = {
       Future{
         processFunc
       } onComplete {
          case Success(result) => {
            requestContext.complete(result)
          }
          case Failure(error) => requestContext.complete(error)
       }
  }
}

class UserWorker(userservice: UserServiceComponent#UserService,requestContext:RequestContext) extends RouteServiceActor{
 def receive = {
    case getusers => processRequest(requestContext){
         userservice.getAllUsers
    }
    context.stop(self)
  }
  case userInfo:UserInfo => {
    processRequest(requestContext){
         userservice.createUser(userInfo)
    }
    context.stop(self) 
 }  

}

```

My first question is, am I handling the request in a true asynchronous fashion? What are some of the pitfalls with my code?

My second question is how does the `requestContext.complete` work? Since the original request processing thread is no longer there, how does the `requestContext` send the result of the computation back to the client.

My third question is that since I am calling `context.stop(self)` after each of my partial methods, is it possible that I terminate the worker while it is in the midst of processing a different message.

What I mean is that while the Actor receives a message to process `getusers`, the same actor is done processing `UserInfo` and terminates the Actor before it can get to the "getusers" message. I am creating new actors upon every request, but is it possible that under the covers, the `actorRefFactory` provides a reference to a previously created actor, instead of a new one?

I am pretty confused by all the abstractions and it would be great if somebody could break it down for me.

Thanks