I have a scenario where we have an EventProcessor actor which has a rate limit on how many events it can process per second.
So, when we tell to the EventProcessor actor, messages get queued up in mailbox because of the rate limit.
So, when the system is restarted the messages in the mailbox will be lost. There should, therefore be a way of persisting the events in the mailbox and replay only those events which are yet to be processed.
Using, Akka Persistence, I thought of doing like this…
- Event source
- The EventSource which is not an actor, will tell the PersistentActor to persist the messages.
- The PersistentActor will persist the messages and tell the EventProcessor actor to process them.
- The EventProcessor will process those messages and will tell the PersistentActor to delete the message which it has finished processing.
- The PersistentActor will receive the message from the EventProcessor about the message that has been processed and remove it from the persistence layer.
Is there any working example?