There are some situations when you want an actor to process certain messages first and then other ones. So, I am going to demonstrate how to create a priority based mailbox for an actor.
Suppose we have an actor.
Now we want to process our messages in order like (string, Int , Long , other messages).
So what we need to do is to just write a priority based mailbox as below.
Here zero denotes highest priority.
After that add this configuration to application.conf.
At the time of actor creation specify the dispatcher class as below.
Suppose you send below messages to actor, in such a case string messages would be picked up first.
You can find the sample code here in github.
How to run the code.
After cloning the repo, go to the console and do sbt run in the project directory, it will show following output in console.