How to build a durable mailbox with Akka Persistence?

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…

  1. Event source
  2. PersistentActor
  3. EventProcessorActor


  1. The EventSource which is not an actor, will tell the PersistentActor to persist the messages.
  2. The PersistentActor will persist the messages and tell the EventProcessor actor to process them.
  3. The EventProcessor will process those messages and will tell the PersistentActor to delete the message which it has finished processing.
  4. 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?