Hi,
I'm trying to understand how dispatchers and execution context work and then especially how you can deal with blocking calls as an API I'm working with unfortunately uses a blocking MongoDB driver.
My idea was to wrap every call in the routing layer with a `detach()` directive, and use a custom dispatcher.
So I do
implicit val system = ActorSystem("spray-pressure")
val serviceCustom = system.actorOf(Props(classOf[RestActor]).withDispatcher("custom-dispatcher"),"rest-api-custom")
IO(Http) ! Http.Bind(serviceCustom, interface = "127.0.0.1", port = 8081)
and then have
detach() {
complete {
"Blocking Db driver"
} }
I thought that this would pickup the custom dispatcher but it does not.
2016-11-16 15:06:36,642 [default-akka.actor.default-dispatcher-7] [routes.DetachedRoute$$anonfun$2] INFO - Blocking Db driver
I guess my question is why not? I mean I could set set the dispatcher explicitlyin the `detach()`. But then what is that dispatcher defined in `withDispatcher` used for?
Cheers,
Oliver
PS
Full project/code here: