Add multi-routing-key bindings to RabbitMQ transport#9864
Merged
PascalSenn merged 10 commits intoJun 7, 2026
Conversation
alisan3
marked this pull request as ready for review
June 7, 2026 06:41
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adds support for multiple routing keys per RabbitMQ binding, deprecating the single RoutingKey property while ensuring bindings can be provisioned for each configured key.
Changes:
- Introduces
RoutingKeysacross binding configuration/runtime objects and provisions one broker binding per key. - Deprecates the single
RoutingKeyproperty while preserving backward-compatible read/write behavior. - Expands unit/integration coverage to validate accumulation, deduplication, and publish routing behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Mocha/test/Mocha.Transport.RabbitMQ.Tests/Topology/RabbitMQTopologyDescriptorTests.cs | Adds tests for accumulating/deduplicating routing keys and obsolete property behavior. |
| src/Mocha/test/Mocha.Transport.RabbitMQ.Tests/Behaviors/RoutingKeyTests.cs | Adds integration test to ensure all bound routing keys receive messages. |
| src/Mocha/src/Mocha.Transport.RabbitMQ/Topology/RabbitMQBinding.cs | Adds RoutingKeys to bindings and provisions one bind per key; obsoletes RoutingKey. |
| src/Mocha/src/Mocha.Transport.RabbitMQ/Topology/Descriptors/RabbitMQBindingDescriptor.cs | Updates descriptor to accumulate/deduplicate keys; adds RoutingKeys(params) API. |
| src/Mocha/src/Mocha.Transport.RabbitMQ/Topology/Descriptors/IRabbitMQBindingDescriptor.cs | Updates docs and adds a default RoutingKeys(params) convenience method. |
| src/Mocha/src/Mocha.Transport.RabbitMQ/Topology/Configurations/RabbitMQBindingConfiguration.cs | Introduces RoutingKeys list and obsoletes RoutingKey with adapter semantics. |
| src/Mocha/src/Mocha.Transport.RabbitMQ/RabbitMQMessagingTransport.cs | Updates transport description output from routingKey to routingKeys. |
| src/Mocha/examples/Demo/Demo.Catalog/diagram.json | Updates diagram properties to use routingKeys. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PascalSenn
approved these changes
Jun 7, 2026
This was referenced Jun 16, 2026
This was referenced Jun 22, 2026
This was referenced Jul 2, 2026
Open
This was referenced Jul 13, 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.
Add multi-routing-key bindings to RabbitMQ transport
Summary
A RabbitMQ binding could previously carry only a single routing key. Binding one queue to several routing keys on the same exchange required declaring multiple bindings, which was verbose and did not reflect how RabbitMQ models bindings (one broker binding per routing key). This PR makes routing keys additive: a binding now holds a list of routing keys, and the transport provisions one broker binding per key between the source and destination.
What changed
RabbitMQBindingConfigurationandRabbitMQBindingnow expose aRoutingKeyscollection instead of a single value. Provisioning iterates the keys and creates oneQueueBind/ExchangeBindper key (falling back to an empty key when none are specified).RoutingKey(string)is now additive — each call accumulates a distinct key (with de-duplication) rather than overwriting.RoutingKeys(params string[])adds multiple keys in a single call; it delegates toRoutingKey, so both forms share one code path.routingKeysarray (the old scalarroutingKeyfield is gone);diagram.jsonfor the demo was regenerated accordingly.Backward compatibility
The previous single-key surface is preserved as
[Obsolete]shims, so existing code keeps compiling:RabbitMQBinding.RoutingKey(read) returns the first key, or empty string when none.RabbitMQBindingConfiguration.RoutingKey(read/write) maps to the first key; setting it replaces the list, settingnullclears it.Both are annotated to be removed in a future release.
Tests
RabbitMQTopologyDescriptorTests): accumulation, de-duplication, declaring the same pair twice, and the obsolete property shims.RoutingKeyTests): topic/wildcard routing, negative (non-matching) routing, routing-key header propagation, and a combined test proving additivity end-to-end using bothRoutingKeys(params)and chainedRoutingKey().RoutingKey()declarations.All RabbitMQ transport tests pass (299/299, including 18 broker-backed classes).