如何从akka演员那里获得消息队列的大小? [英] how to get the size of message queue from akka actor?

查看:189
本文介绍了如何从akka演员那里获得消息队列的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序中有Akka(Java API)actor(UntypeActor)和消息。
根据API合同,如果有几条消息发送给同一个演员,它们会被排队并逐个处理。

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.

我是喜欢根据队列大小处理actor中的消息。基本上:在Actor.onReceive()中处理当前的消息时,是否至少还有一个消息排队?什么是Akka存档的方式?

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?

推荐答案

在你执行的UntypedActor中:

From within the UntypedActor you do:

getContext()。getMailboxSize();

getContext().getMailboxSize();

这篇关于如何从akka演员那里获得消息队列的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆