0

I'm working with RabbitMQ and Spring amqp where I would prefer not to lose messages. By using exponential back off policy for retrying, I'm potentially blocking my consumers which they could be working off on messages they could handle. I'd like to give failed messages several days to retry with the exponential back off policy, but I don't want a consumer blocking for several days and I want it to keep working on the other messages.

I know we can achieve this kind of functionality with ActiveMQ(Retrying messages at some point in the future (ActiveMQ)), but could not find a similar solution for RabbitMQ.

Is there a way to achive this with Spring amqp and RabbitMQ?

Community
  • 1
  • 1
abhi
  • 41
  • 3

1 Answers1

0

You can do it via the dead letter exchange. Reject the message and route it to the DLE/DLQ and have a separate listener container that consumes from the DLQ and stop/start that container as needed.

Or, instead of the second container you can poll the DLQ using the RabbitTemplate receive (or receiveAndConvert) methods (on a schedule) and route the failed message(s) back to the primary queue.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • I'm more inclined towards the latter solution. But in my case, I only want to retry if its a retry-able exception, others I will move them to a DLQ through a custom recoverer. When I poll the DLQ, I will be interested in those messages that failed due to a retry-able exception. – abhi Jun 30 '14 at 15:52