ActiveMQ中的setBackOffMultiplier(double backOffMultiplier)是如何工作的

How does setBackOffMultiplier(double backOffMultiplier) in ActiveMQ work

我正在使用 activemq 编写一个应用程序,我在其中使用重新传递策略来重新传递消息。我正在使用 ActiveMQ 的 ExponentialBackOff 概念。

我的问题是 ExponentialBackOff/setBackOffMultiplier 是如何工作的。

例如,在我的例子中,我想重新传递消息直到消息过期时间,即 15 minutes.I 想尝试在 15 之内重新传递 10 次 minutes.But ExponentialBackOff 使消息重新传递超过消息的 15 分钟到期时间,即即使在 15 分钟的到期时间之后,要重新传递的消息仍处于挂起状态。

这是为什么?我对这种行为感到困惑。我使用的重新投递政策如下。

RedeliveryPolicy queuePolicy = new RedeliveryPolicy();
queuePolicy.setInitialRedeliveryDelay(0);
queuePolicy.setBackOffMultiplier(3);
queuePolicy.setUseExponentialBackOff(true);
queuePolicy.setMaximumRedeliveries(10);

使用此 RedeliveryPolicy 配置,RedeliveryPolicy 将在每次等待后进行尝试:

after 1s
after 3s
9s
27s
81s
243s
729s
2187s
6561s
19683s

如您所见,尝试在数小时后执行,同时您看到消息状态为待处理。 为了防止这些长时间,您可能需要设置 maximumRedeliveryDelay=300000L (5 分钟)。 请注意

Once a message's redelivery attempts exceeds the maximumRedeliveries configured for the Redelivery Policy, a "Poison ack" is sent back to the broker letting him know that the message was considered a poison pill. The Broker then takes the message and sends it to a Dead Letter Queue so that it can be analyzed later on.

您需要调整您的 RedeliveryPolicy,因为只要不超过 maximumRedeliveries,消息就会处于待处理状态。

http://activemq.apache.org/message-redelivery-and-dlq-handling.html