Aleksei Teploukhov
Aleksei Teploukhov

Reputation: 23

Creating quorum queues by Sender in RabbitMQ by MassTransit

I use MassTransit and RabbitMQ quorum queue for application integration. I send message using

var endpoint = await _bus.GetSendEndpoint(new Uri("exchange:TestCommand"));
await endpoint.Send(command1, stoppingToken);

If "receiver application" doesn't ever start, queue won't be created and all sent messages will be lost.

If I use prefix queue for send:

var endpoint = await _bus.GetSendEndpoint(new Uri("queue:TestCommand"));
await endpoint.Send(command, stoppingToken);

classic queue will be created (not quorum). And I can't change queue type later.

I don't want to think about "receiver application" starting moment and I don't want to loose sent messages. How I can create RabbitMQ quorum queue by sender application using MassTransit?

Upvotes: 2

Views: 835

Answers (2)

Ykok
Ykok

Reputation: 1415

This post explains how to configure so the mandatory flag is set on all messages sent. It is not a direct solution to your question, but it will ensure messages is not lost when sending to an exchange that does not have any bindings.

Upvotes: 0

Chris Patterson
Chris Patterson

Reputation: 33457

The general guidance is simple, don't couple your producers to your consumers.

You can start the receiver first so that it configures the queue properly (including the quorum settings).

Or you can set the Mandatory flag (RabbitMQ specified) so that Send throws an exception if the message is not delivered to a queue, and return to sending to the exchange.

Upvotes: -1

Related Questions