Reputation: 83
I am using Masstransit. I would like to avoid to create an exchange for the endpoint and would rather have the endpoint queue to bind directly to the publishing exchange.
This is my code
cfg.Message<Notification>(x => { x.SetEntityName("NOTIFICATION_REQUEST"); });
g.ReceiveEndpoint("notification-workerQ", e =>
{
e.Consumer<NotificationConsumer>();
});
This creates
Is there a way to avoid notification-workerQ exchange and have the queue directly bound to NOTIFICATION_REQUEST exchange?
Additional question
I am asked to not create an exchange at all but use an already existing topic exchange that I bind my queue to using routing keys.
That means my notification-workerQ should bind to GENERIC_DROP exchange using a routingkey like "componentX.something.notification"
Maybe something like
g.ReceiveEndpoint("notification-workerQ", e =>
{
e.Consumer<NotificationConsumer>(x =>
{
//THIS IS NOT WORKING CODE
x.consumeFrom("GENERIC_DROP", "ROUTING_KEY")
});
});
Upvotes: 1
Views: 3561
Reputation: 33457
There is no way to prevent MassTransit from creating the notification-workerQ
exchange, as MassTransit always creates a matching exchange for a queue.
You can, however, bind your existing topic exchange, with routing key, by configuring the receive endpoint as shown below.
e.Bind("NOTIFICATION_REQUEST", x =>
{
x.RoutingKey = "ROUTING_KEY";
x.ExchangeType = ExchangeType.Topic;
});
There is also a sample that shows how to use direct exchanges, topic exchanges are configured the same way.
Upvotes: 2