Reputation: 1045
I have readed the online documentation of the Akka.NET.
I see that the Persistence Plugin can storage the actor's state using Event Source pattern.
But I did not find anything specific about the messages in mailbox.
When one process die or restart, the actor's mailbox recover messages?
Upvotes: 3
Views: 728
Reputation: 7542
Actor's mailbox is always in-memory only. In actor systems messages are not only commands related to user domain, but also a variety of signals used to control actor lifecycle, implement protocol communication etc. Therefore the volume of messages in-flight is much higher than i.e. when using message brokers. They must be passed and handled at much higher speeds, and mailbox persistence would heavily slow that process.
If you need to persist your commands from your domain, the simplest way would be to just use some sort of persistent message queue - like RabbitMQ, Azure Service Bus or even Kafka - as a facade in front of your actor system to handle incoming user requests.
Upvotes: 3
Reputation: 2278
According to documentation and experience, not an actor state is persisted but events that changed state, which then applying after the restart of the actor.
Messages during Persist() or Recover() are going to stash, and both mailbox and stash are saved while actor restart
("An actor restart replaces only the actual actor object; the contents of the mailbox is unaffected by the restart, so processing of messages will resume after the PostRestart hook returns. The message that triggered the exception will not be received again. Any message sent to an actor while it is being restarted will be queued to its mailbox as usual." and "Stashes are handled by Akka.NET out of the actor instance just like the mailbox, so if the actor dies while processing a message, the stash is preserved.")
But it's for normal restart, take a look at AtLeastOnceDeliveryActor, maybe it's what you are looking for guaranteed delivery. And pay attention to preRestart() method to save currently processing message while restarting.
Upvotes: 1