Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the size of message queue from akka actor?

Tags:

java

akka

There are Akka (Java API) actors (UntypeActor) and messages in the application. According to API contract in case a few messages are addressed to the same actor, they are queued and processed with one-by-one.

I'd like to handle messages in the actor depending on queue size. Basically: is there at least one more message queued at the moment current one is handled in Actor.onReceive()? What is the Akka way to archive this?

like image 212
Alexander Vasiljev Avatar asked Mar 17 '11 18:03

Alexander Vasiljev


1 Answers

From within the UntypedActor you do:

getContext().getMailboxSize();

like image 179
Jonas Bonér Avatar answered Oct 17 '22 21:10

Jonas Bonér