Rule #1 of Akka: don’t block inside actors. If you do have blocking / high latency calls, wrap them in a future and toss them into a different execution context specifically meant for high latency tasks.
12345678910111213141516171819202122
importjava.util.concurrent.ExecutorsclassClassyActorextendsActor{valnumThreads=10valpool=Executors.newFixedThreadPool(numThreads)valctx=ExecutionContext.fromExecutorService(pool)defreceive:Actor.Receive={// An message that needs some high latency work donecasem:Message=>valfuture=Future{// do something with m: Message}(ctx)future.onComplete({caseSuccess(s)=>// do something when the task successfully completedcaseFailure(f)=>// do something when the task failed})(ctx)}}