Reputation: 2733
I want to receive async acknowledgements that a message has, in fact, been placed in a queue. I've searched quite a bit, and tried various ways of using EasyNetQ's PublishAsync
for confirmations, but can't seem to find the Bus
connection configuration and code combination that will give me such an acknowledgement.
Perhaps PublishAsync
is not the way to go for this, and I've overlooked something else in the EasyNetQ API? Anyone else have experience with implementing this scenario with EasyNetQ?
Upvotes: 1
Views: 2329
Reputation: 1454
The official documentation on Publish Confirm states that
For unroutable messages, the broker will issue a confirm once the exchange verifies a message won't route to any queue (returns an empty list of queues)
This means that you will get a Publish Confirm, even though there is no queues bound to the exchange with matching routing key. If you want to make sure that the message is published to at least one queue, you need to make sure that the mandatory flag is set to true
in the BasicPublish
channel.BasicPublish(
exchange: "my_exchange",
routingKey:"routingkey",
mandatory: true, // at least one queue
basicProperties: null,
body: new byte[0]
);
The default value when mandatory is not provided is false
. So Mike Hadlow's answer is not 100% accurate. There is an open issue for RawRabbit
regarding this, that is due in the next release.
Upvotes: 1
Reputation: 9517
For that kind of guarantee you need to turn on publisher confirms. See the documentation:
https://github.com/mikehadlow/EasyNetQ/wiki/Publisher-Confirms
Upvotes: 1