简体   繁体   English

如何从akka演员那里获得消息队列的大小?

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

There are Akka (Java API) actors (UntypeActor) and messages in the application. 应用程序中有Akka(Java API)actor(UntypeActor)和消息。 According to API contract in case a few messages are addressed to the same actor, they are queued and processed with one-by-one. 根据API合同,如果将一些消息发送给同一个actor,它们将被排队并逐个处理。

I'd like to handle messages in the actor depending on queue size. 我想根据队列大小处理actor中的消息。 Basically: is there at least one more message queued at the moment current one is handled in Actor.onReceive()? 基本上:在Actor.onReceive()中处理当前的消息时,是否至少还有一个消息排队? What is the Akka way to archive this? 什么是Akka存档方式?

From within the UntypedActor you do: 从UntypedActor中你可以:

getContext().getMailboxSize(); 。的getContext()getMailboxSize();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM