Ha Pham
Ha Pham

Reputation: 413

MassTransit republish message for another consumer when a consumer throws exception

I am developing a micro-services system using MassTransit and RabbitMQ. One service can publish jobs to many subscriber services. One of subscribers will execute the job (Competing consumer).

If one subscriber consume a message, execute a job and throw an exception, is there any way to get the message re-delivered to the queue, so that other subscribers can consume that message.

I use retry policy for the subscribers, but it only allows me to re-consume the message inside the same subscriber, not consume by another subscriber.

Upvotes: 0

Views: 1548

Answers (1)

Chris Patterson
Chris Patterson

Reputation: 33233

You can schedule redelivery of the message:

http://masstransit-project.com/MassTransit/usage/scheduling/redeliver.html

You need to have a message scheduler, or use the delayed exchange in RabbitMQ. Typically retrying immediately is discouraged, but you can set the redelivery timer to anything you want.

Upvotes: 1

Related Questions