I have a bunch of actors that are sending a lot of messages to each other. It is very likely that the default queue for these actors would cause a lot of actors to run out of memory.
Ideally this is what I want to happen:
A
sends toB
.B
says "I'm too full for letterL
."A
is told this, and storesL
(possibly in hard drive).A
continues working.- Once
A
is idle, he looks back at any letters and finds letters likeL
that actors (such asB
) were too full to consume. A
attempts to resendL
toB
.- Process keeps repeating.
From what I have read I need to switch to a blocked queue. My impression is if A
sends a message to B
, but B
s mailbox is full, B
will say "I'm full" and cause a timeout. This then gets sent to a DeadLetterActorRef
called D
.
The problem is adapting Akka's "dead letter paradigm" to the steps described above. At step 3, I need a way of telling A
it failed and the letter should be saved for later. It seems that you "tell" these actors by having them subscribe
to the DeadLetter
event bus. That forces me to have every actor subscribed to the DeadLetter
event bus. If A
failed to send a message and B
failed to send a message both A
and B
s message would be sent to the DeadLetter
queue and both have to sort through each other's dead letters to find the one they need. This seems inefficient. Is there a better way to go about this?
Note: I do not want to load balance the dead letters, which some articles suggest doing with the dead letter queue.
See Question&Answers more detail:os