Domanda

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.

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top