feat(rabbitmq): support per-exchange bindings in RabbitSubscribe#1152
Merged
feat(rabbitmq): support per-exchange bindings in RabbitSubscribe#1152
Conversation
…Subscribe via bindings option Co-authored-by: underfisk <15980884+underfisk@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for specifying exchange per routing key in RabbitSubscribe
feat(rabbitmq): support per-exchange bindings in RabbitSubscribe
Mar 17, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for binding a single subscriber queue to routing keys across multiple exchanges via a new bindings option on @RabbitSubscribe, enabling multi-exchange consumption in one handler while keeping existing exchange/routingKey behavior intact.
Changes:
- Introduces
RabbitSubscribeBindingandbindings?: RabbitSubscribeBinding[]onMessageHandlerOptions. - Extends queue setup to apply multiple
channel.bindQueue()calls based onbindings(in addition to existingexchange/routingKeybinding). - Adds documentation and E2E coverage for multi-exchange bindings.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/rabbitmq/src/rabbitmq.interfaces.ts | Adds the binding shape (RabbitSubscribeBinding) and the new bindings option to handler options with JSDoc. |
| packages/rabbitmq/src/amqp/connection.ts | Applies per-binding queue bindings during setupQueue() by iterating bindings. |
| integration/rabbitmq/e2e/subscribe.e2e-spec.ts | Adds E2E scenarios verifying messages are received from each exchange binding and both combined. |
| docs/modules/rabbitmq.md | Documents how to bind a single queue to routing keys across multiple exchanges using bindings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+1125
to
+1134
| await Promise.all( | ||
| bindings.map(({ exchange: bindingExchange, routingKey: bindingKey }) => | ||
| channel.bindQueue( | ||
| actualQueue as string, | ||
| bindingExchange, | ||
| bindingKey, | ||
| bindQueueArguments, | ||
| ), | ||
| ), | ||
| ); |
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.
Currently
@RabbitSubscribeonly supports binding a queue to a single exchange, even when multiple routing keys are specified. This adds abindingsoption that allows binding one queue to routing keys across multiple exchanges in a single handler.Changes
rabbitmq.interfaces.ts— NewRabbitSubscribeBindinginterface (exchange,routingKey); addsbindings?: RabbitSubscribeBinding[]toMessageHandlerOptionswith JSDocconnection.ts—setupQueue()processes thebindingsarray and callschannel.bindQueue()for each entry; fully additive alongside existingexchange/routingKeybehaviordocs/modules/rabbitmq.md— New "Binding a Queue to Multiple Exchanges" section with usage examplesUsage
bindingscan be combined with the top-levelexchange/routingKey— both sets of bindings are applied. Fully backward-compatible.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
mise.run/usr/bin/curl curl -sSf REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.