"Dispatchers in Akka Dispatchers are used to control the flow of execution in Akka - they can control how messages are being sent, delivered, received and processed. Based on the dispatching policy, dispatchers will route the incoming message to the respective destination. Dispatchers are what make Akka 'tick'. There are a number of different dispatchers that Akka provides readily, and also lets you write your own implementation, should you need. Here are a few dispatchers that come out of the box with Akka"
"This is an event-based dispatcher that binds an actor to a thread pool. It is based on a Java ExecutorService-backed thread pool. Creates and maintains one mailbox per actor Can be shared between several actors of the same or different types Dedicates a unique thread for each actor. In other words, each actor is backed by a single thread pool of size 1. The assigned thread is deallocated after a certain period of inactivity."
"Here's an example of a dispatcher configuration : my-thread-pool-dispatcher { type = Dispatcher executor = "thread-pool-executor" thread-pool-executor { core-pool-size-min = 2 core-pool-size-factor = 2 core-pool-size-max = 10 } throughput = 5000} To use it, specify the dispatcher name as an argument to the withDispatcher method : val config = ConfigFactory.load.getConfig( "config\\application.conf" )val system = ActorSystem ("my-actor-system", config )val myActor = system.actorOf(Props[MyActor].withDispatcher("my-thread-pool-dispatcher"),"
Akka dispatchers control execution flow and route incoming messages to destinations according to dispatching policy. Multiple built-in dispatcher types are available and custom implementations are allowed. An event-based dispatcher binds an actor to a Java ExecutorService-backed thread pool and typically creates one mailbox per actor. A pinned dispatcher dedicates a unique thread to each actor and deallocates the thread after inactivity, with no sharing. Dispatchers can bind multiple actors of the same type to a shared mailbox acting as a load balancer. Configuration and withDispatcher usage allow assignment of named dispatchers to actors.
Read at Medium
Unable to calculate read time
Collection
[
|
...
]