Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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:

  1. A sends to B.
  2. B says "I'm too full for letter L."
  3. A is told this, and stores L (possibly in hard drive). A continues working.
  4. Once A is idle, he looks back at any letters and finds letters like L that actors (such as B) were too full to consume.
  5. A attempts to resend L to B.
  6. 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 Bs 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 Bs 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
223 views
Welcome To Ask or Share your Answers For Others

1 Answer

The behavior you are looking for is called "back pressure". In akka that is supported using akka streams see this presentation https://www.lightbend.com/blog/understanding-akka-streams-back-pressure-and-asynchronous-architectures


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...