Suggest to use multiple delayed queues for each queue instead of single #53
Open
roveil wants to merge 3 commits into
Open
Suggest to use multiple delayed queues for each queue instead of single #53roveil wants to merge 3 commits into
roveil wants to merge 3 commits into
Conversation
The main task queue was declared with a per_queue_arguments dict that was then mutated in place to set the delay queue's dead-letter args. aio-pika keeps a reference to that dict for re-declaring the queue on robust reconnect, so after mutation the main queue would be re-declared with the delay queue's x-dead-letter-exchange, causing a precondition_failed inequivalent-arg channel exception on every reconnect. Build the delay queue arguments in a separate dict so the main queue's stored arguments stay unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Previously, the broker supported a single global
delay_queueparameter that had to be configured manually. This approach didn't scale well when using multiple task queues — there was no way to delay a message and route it back to a specificqueue.
This PR replaces the single
delay_queuewith per-queue delay queues that are automatically created for each task queue on startup (whendelayed_message_exchange_pluginis not used).Changes
delay_queueparameter fromAioPikaBroker.__init__{queue_name}.delay, withx-dead-letter-exchangeandx-dead-letter-routing-keypointing back to its parent queueQueue:queue_routing_key,delay_queue_name,delay_queue_routing_keyMotivation
When using multiple task queues, the old single
delay_queuecould only route delayed messages back to one queue. With per-queue delay queues, each task queue gets its own delay queue, so delayed messages are always routed back to the correctqueue regardless of how many queues the broker has.
Breaking changes
delay_queueparameter has been removed fromAioPikaBroker. Users who previously configured a custom delay queue should migrate to the new automatic behavior. The delay queue is now created automatically on startup.