重新发送Akka中的一封死信 [英] Resending a dead letter in Akka

查看:136
本文介绍了重新发送Akka中的一封死信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆演员互相发送大量消息。这些参与者的默认队列很可能会导致许多参与者的内存不足。

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 发送到 B

  2. B 说:我对字母 L 太满了。

  3. A 被告知,并存储 L (可能存储在硬盘中) )。 A 继续工作。

  4. A 空闲后,他回头看任何字母并发现像 L 之类的字母(例如 B )演员都太满而无法使用。

  5. A 尝试将 L 重新发送到 B

  6. 过程不断重复。

  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.

我已阅读,我需要切换到阻止的队列。我的印象是,如果 A B 发送消息,但 B 邮箱已满, B 会说我已满并导致超时。然后将其发送到名为 D DeadLetterActorRef

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.

问题在于使Akka的死信范式适应上述步骤。在第3步中,我需要一种方法来告诉 A 失败,并且应该保存该信件以备后用。似乎您通过让他们 subscribe DeadLetter 事件总线来告诉这些演员。这迫使我让每个演员都订阅了 DeadLetter 事件总线。如果 A 发送失败,而 B 发送失败,则两个 A B s消息将发送到 DeadLetter 队列,并且两者都必须对彼此的消息进行排序死信找到他们需要的。这似乎效率低下。有没有更好的方法可以解决这个问题?

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.

推荐答案

您正在寻找的行为称为反压力。
在使用akka流支持的akka​​中,请参见此演示文稿
https://www.lightbend.com/blog/understanding-akka-streams-back-pressure-and-asynchronous-architectures

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

这篇关于重新发送Akka中的一封死信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆