Skip to content

ARTEMIS-6311 Preserve delivery count on redistribution - #6874

Open
leisma wants to merge 1 commit into
apache:mainfrom
leisma:delivery-count-with-redistribution
Open

leisma wants to merge 1 commit into
apache:mainfrom
leisma:delivery-count-with-redistribution

Conversation

@leisma

@leisma leisma commented Nov 6, 2026 •

Copy link
Copy Markdown

The delivery count is tracked on the MessageReference, so a message that is redistributed to another broker of the cluster starts over at zero. This causes max-delivery-attempts to be enforced per broker instead of cluster wide.

The originating broker now carries the delivery count over on the redistributed copy via the _AMQ_REDISTRIBUTION_DELIVERY_COUNT property, which the target broker applies when it creates the MessageReference. The behavior is gated by the new address setting preserve-delivery-count-on-redistribution (default false).

The property is set between redistribute() and processRoute(): earlier it would be reset by clearInternalProperties(), later the MessageReference already exists. For the same reason it is not an internal property, so it stays visible to clients on the target broker, like _AMQ_INGRESS_TIMESTAMP.

The target broker only applies the count if the receiving queue has the setting enabled itself (internal queues such as store-and-forward are skipped), and only reads the property in that case, so a broker with the feature off pays nothing. Asymmetric configurations and rolling upgrades are therefore safe.

Supporting changes:

  • PostOfficeJournalLoader restores the count on reload as max(stored count, preserved count) for queues with the setting enabled. A redistributed but not yet redelivered message has no UPDATE_DELIVERY_COUNT record, so the preserved count is all there is.
  • QueueImpl.makeCopy() removes the property so the count does not leak into dead letter or expiry copies, which must start at 1.
  • Redistributor removes a leftover property when the setting is disabled, so a stale count is not reapplied.
  • Message gets accessors for the property and removeBrokerProperty(); AMQPMessage overrides it to remove both the annotation and the extra property.

The setting defaults to false, so existing behaviour is unchanged. RedeliveryWithRedistributionClusterTest covers the baseline, the default reset, the preserved count, restart, asymmetric configuration and a client-supplied property.

https://issues.apache.org/jira/browse/ARTEMIS-6311

@jbertram

Copy link
Copy Markdown
Contributor

This looks pretty good. However, there are a few issues that need to be resolved. However, rather than go back and forth here I just push a branch with everything I think is needed. Feel free to pull this in and squash it with your own commit.

The delivery count is tracked on the MessageReference, so a message that is redistributed to another broker of the cluster starts over at zero, causing max-delivery-attempts to be enforced per broker instead of cluster wide.

The originating broker now carries the delivery count over on the redistributed copy via _AMQ_REDISTRIBUTION_DELIVERY_COUNT, which the target broker applies when it creates the MessageReference. The behavior is gated by the new address setting preserve-delivery-count-on-redistribution and is disabled by default

Assisted-by: Justin Bertram
Signed-off-by: Marc Leisi <137479805+leisma@users.noreply.github.com>
@leisma
leisma force-pushed the delivery-count-with-redistribution branch from c82ebbb to 21db157 Compare November 19, 2026 19:38
@leisma

leisma commented Nov 19, 2026

Copy link
Copy Markdown
Author

This looks pretty good. However, there are a few issues that need to be resolved. However, rather than go back and forth here I just push a branch with everything I think is needed. Feel free to pull this in and squash it with your own commit.

Thanks for the review and the changes @jbertram . I pulled your commit in and squashed it with mine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants