Honor the delivery_mode argument in Exchange.Message - #2570
Merged
auvipy merged 1 commit intoJul 25, 2026
Conversation
Exchange.Message accepts a delivery_mode argument and documents it as 'Set custom delivery mode. Defaults to :attr:delivery_mode', but the body always used self.delivery_mode, so the caller's value was discarded. Asking for a transient message on a persistent exchange still produced delivery_mode=2, and vice versa. Fall back to the exchange default only when no delivery mode is given, matching Producer._delivery_details, which already does 'delivery_mode or exchange.delivery_mode'. Exchange.publish() passes no delivery mode, so its behaviour is unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2570 +/- ##
=======================================
Coverage 82.81% 82.81%
=======================================
Files 79 79
Lines 10333 10333
Branches 1187 1187
=======================================
Hits 8557 8557
Misses 1575 1575
Partials 201 201 ☔ View full report in Codecov by Harness. |
auvipy
self-requested a review
July 25, 2026 14:03
auvipy
approved these changes
Jul 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Exchange.Messageaccepts adelivery_modeargument and documents it as:but the method body never uses it — it always calls
maybe_delivery_mode(self.delivery_mode), so the caller's value is silently discarded:So a caller asking for a
transientmessage on a persistent exchange still getsdelivery_mode=2(RabbitMQ fsyncs and persists it), and one asking to persist can silently end up transient.The sibling
Producer._delivery_detailsalready handles this correctly:This change makes
Exchange.Messageuse the same idiom, falling back to the exchange default only when no delivery mode is passed.Exchange.publish()callsself.Message(message)with nodelivery_mode, soNone or self.delivery_modereproduces the current behaviour exactly — nothing changes for existing callers.Added
t/unit/test_entity.py::test_Exchange::test_create_message_delivery_mode, which fails before this change and passes after (the argument overrides the exchange default; without it the default is used).pytest t/unit/test_entity.py t/unit/test_messaging.py→ 128 passed;flake8(max-line-length 117) clean.