How to correctly configure publishing messages to a topic exchange using CommunityToolkit.Aspire.MassTransit.RabbitMQ? #901
Unanswered
denis-bredun-work
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have two separate projects – a publisher and a consumer. I’m using MassTransit, and to simplify configuration I’m using the NuGet package CommunityToolkit.Aspire.MassTransit.RabbitMQ.
My publisher setup:
My consumer setup:
Consumer:
Consumer definition:
Publishing messages:
When I check RabbitMQ management, I see the following setup:
This indicates that MassTransit automatically creates an exchange and a queue for the message type (PostPlatformMessage) as fanout, even though I configured a topic exchange. As a result, the consumer receives all messages of this type regardless of the routing key.
I want messages to be routed based on the RoutingKey to the correct consumer, so that only messages matching the consumer’s configured routing key are delivered to it, using a topic exchange.
Currently, my consumer receives messages that should be routed to other consumers based on the routing key. Even though I configure the exchange as topic and set routing keys for both publishing and binding, messages seem to be delivered to the consumer regardless of the routing key.
Could someone advise why this might be happening and how to correctly configure MassTransit + Aspire + RabbitMQ to respect routing keys when publishing to a topic exchange?
Beta Was this translation helpful? Give feedback.
All reactions