Skip to content

Suggest to use multiple delayed queues for each queue instead of single #53

Open
roveil wants to merge 2 commits intotaskiq-python:masterfrom
roveil:master
Open

Suggest to use multiple delayed queues for each queue instead of single #53
roveil wants to merge 2 commits intotaskiq-python:masterfrom
roveil:master

Conversation

@roveil
Copy link

@roveil roveil commented Mar 5, 2026

Summary

Previously, the broker supported a single global delay_queue parameter 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 specific
queue.

This PR replaces the single delay_queue with per-queue delay queues that are automatically created for each task queue on startup (when delayed_message_exchange_plugin is not used).

Changes

  • Removed delay_queue parameter from AioPikaBroker.__init__
  • Added automatic delay queue declaration for each task queue, named {queue_name}.delay, with x-dead-letter-exchange and x-dead-letter-routing-key pointing back to its parent queue
  • Added three helper properties to Queue: queue_routing_key, delay_queue_name, delay_queue_routing_key
  • Updated tests to reflect the new behavior

Motivation

When using multiple task queues, the old single delay_queue could 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 correct
queue regardless of how many queues the broker has.

Breaking changes

  • delay_queue parameter has been removed from AioPikaBroker. Users who previously configured a custom delay queue should migrate to the new automatic behavior. The delay queue is now created automatically on startup.

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.

1 participant