If an actor starts up and subscribes to a channel in an Akka Event Bus, is there any way for the actor to consume events that were already sent to the channel but not consumed by any other actor?

In other words, I want the actor to "collect mail". Maybe an Event Bus is wrong for this, I don't know.

有帮助吗?

解决方案

If there is no subscription for a channel the messages are sent to the DeadLetter channel. In theory you could write a custom actor and subscribe it to the Deadletter event stream (take a look at the logger actor for DeadLetter) to track all unconsumed messages. You can a have a bound by size queue("last n messages mailbox") in the actor for each channel and make it listen to a custom channel "mail". The mail box queue can be based also on an external persistence(redis,rdbs etc). Every new subscriber for you channel should check the "mail" channel and consume all messages from the specific topic queue in the mail actor, if any. This emulates a regular message queue on any persistence enabled broker.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top