Multiple dispatcher for spray

323 views Asked by At

I am wondering how to handle this specific case.

I have two ClientService that I want to provide to to a web application. By clientService, I mean client API that calls some external rest service. So we are in spray client here.

The thing is, one of the two service can be quite intensive and time consuming but less frequently called than the other one, which will be quicker but with very frequent calls.

I was thinking of having two dispatchers for the two clientService. Let's say we have the query API (ClientService1) and the classification API (ClientService2)

Both service shall indeed be based on the same actor system. So in other words, I would like to have two dispatcher in my actor system, then pass them to spray via the client-level api, for instance pipeline.

  1. Is it feasible, scalable and appropriate?
  2. What would you recommend instead to use one dispatcher but with a bigger thread pool?
  3. Also, how can I obtain a dispatcher?
  4. Should I create a threadpool executor myself and get a dispatcher out of it?
  5. How do I get an actor system to load/create multiple dispatcher, and how to retrieve them such that to pass them to the pipeline method?

I know how to create an actor with a specific dispatcher, there are example for that, but that is a different scenario. I would not like to have lower than the client level API by the way

Edit

I have found that the system.dispatchers.lookup method can create one. So that should do.

However the thing that is not clear is related to AKK.IO/SPRAY.IO.

  1. The manager IO(HTTP): it is not clear to me on which dispatcher it runs or if it can be configured.

  2. Moreover, let's say I pass a different execution context to the pipeline method. What happens? I will still have IO(HTTP) running on the default execution context or its own (I don't know how it is done internally) ? Also what exactly will be ran on the execution context that I pass ? (in other words, which actors)

0

There are 0 answers