mirror of
https://github.com/apache/activemq.git
synced 2025-02-08 19:15:20 +00:00
(cherry picked from commit 393a696955cbf97b90576e4a85b3ce1a02268ad7) Scenario on client: 1. Employing RedeliveryPolicy with exponential backoff (keeping maximum redeliveries at default 6) 2. Enabled non-blocking redelivery 3. Receiving e.g. 100 consecutive poison messages (which eventually should DLQ after max redeliveries) This will result in massive redelivery delays due to a logic bug. The reason is that redeliveryDelay is a field variable kept on the ActiveMQMessageConsumer, instead of being a property on the message - or that the redelivery delay was calculated per message based on the redelivery count. When consecutive messages rollbacks multiple times, the redeliveryDelay field is continuously multiplied by the backoff multiplier, resulting in enormous delays. Fix: Ditch the field variable, instead calculating the redeliveryDelay per delivery from the redelivery count. (This happens to be identical to how it is done in afterRollback() in ActiveMQSession:1004.) Test is added - which fails with the previous code, and passes with this. Added a debug log line for the calculated delay.