How to handle failed publish with RabbitMq?

6.6k views Asked by At

We are planning to use RabbitMq for our messaging service, we'll publish all the message requests to a RabbitMq durable queue.

For .Net client we've decided to use EasyNetQ, so the question is how should we handle RabbitMq server being while publishing a message?

  • Should we catch exception and save the message to database and re-publish with scheduled job?
  • Should we use circuit-breaker?
  • or what else? I'd like to hear your experiences.
1

There are 1 answers

0
Gabriele Santomaggio On BEST ANSWER

In general if you want to be sure about the publish you can use the publish confirmation.

as you can read, you can do that using the transactions or with ConfirmListener.

To handle the broker fails, you can store locally the failed messages then try to re-send them after x seconds.

Note: I don't know how EasyNetQ works, but the native publish is asynchronous, so trap the publish exceptions is not enough. That's why you should use publish confirm to deal with it.