Adds routing key support for rabbitmq#9481
Conversation
There was a problem hiding this comment.
Pull request overview
Adds RabbitMQ topic-exchange routing key support by allowing message types to define a routing key extractor, propagating it via dispatch middleware into the envelope headers, and having the RabbitMQ dispatch endpoint publish with that routing key.
Changes:
- Introduces a per-
MessageTypefeature collection and wires it up from configuration to runtime. - Adds RabbitMQ routing key configuration (
UseRabbitMQRoutingKey) + dispatch middleware to set the routing key header. - Updates RabbitMQ dispatch to read the routing key header and includes unit + integration tests for routing behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Mocha/test/Mocha.Transport.RabbitMQ.Tests/RabbitMQRoutingKeyTests.cs | Unit tests validating extractor storage on MessageType.Features and middleware header behavior. |
| src/Mocha/test/Mocha.Transport.RabbitMQ.Tests/Behaviors/RoutingKeyTests.cs | Integration tests verifying topic binding routing and routing-key header propagation. |
| src/Mocha/src/Mocha/MessageTypes/MessageType.cs | Adds Features to MessageType and initializes from configuration features. |
| src/Mocha/src/Mocha.Transport.RabbitMQ/Topology/Extensions/RabbitMQTransportDescriptorExtensions.cs | Registers routing-key dispatch middleware before serialization in RabbitMQ defaults. |
| src/Mocha/src/Mocha.Transport.RabbitMQ/RabbitMQRoutingKeyExtractor.cs | Defines internal feature object for extracting routing keys from messages. |
| src/Mocha/src/Mocha.Transport.RabbitMQ/RabbitMQRoutingKeyExtensions.cs | Adds public descriptor extension to configure routing key extraction per message type. |
| src/Mocha/src/Mocha.Transport.RabbitMQ/RabbitMQMessageHeaders.cs | Adds RoutingKey typed header key constant. |
| src/Mocha/src/Mocha.Transport.RabbitMQ/RabbitMQDispatchEndpoint.cs | Uses the routing key header when publishing to an exchange. |
| src/Mocha/src/Mocha.Transport.RabbitMQ/Middlewares/Dispatch/RabbitMQRoutingKeyMiddleware.cs | Dispatch middleware that writes routing key into dispatch headers when configured. |
| src/Mocha/src/Mocha.Transport.RabbitMQ/Middlewares/Dispatch/RabbitMQDispatchMiddlewares.cs | Exposes a preconfigured dispatch middleware entry for routing key extraction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9481 +/- ##
==========================================
- Coverage 74.16% 0 -74.17%
==========================================
Files 2677 0 -2677
Lines 140790 0 -140790
Branches 16371 0 -16371
==========================================
- Hits 104421 0 -104421
+ Misses 30774 0 -30774
+ Partials 5595 0 -5595
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.