0

Scenario: A microservice picks up a message from a RabbitMQ Queue, it's converted to an object and then the microservice makes a REST call to external service.

It's going to deal with thousands 'n thousands of these messages, is there a way of telling my consumer not to pick up a message off the Queue if we know the external Rest service is down?

I know I can do retries for an individual message once it's picked up, but I dont want to even pick it up if I know its down. I dont want to deal with thousands of messages in DLQ.

Also it feels like a Circuit Breaker design pattern, but I cant find any specific examples of how to implement it with AMQP.

Extra info: SpringBoot app, taking to RabbitMQ using spring amqp.

Thanks in advance

sdiaz1000
  • 27
  • 6
  • Well, since you're starting event is the reception of a message, this seems highly unlikely. You could implement a health check to you Rest Service on a timer, and stop the listener on messages when service is down? – DTul Mar 22 '19 at 14:45

1 Answers1

1

You can stop and start the message listener container.

If you are using discrete containers you can stop/start the container bean.

If you are using @RabbitListener, provide an id attribute and wire in the RabbitListenerEndpointRegistry bean.

Then registry.getMessageListenerContainer(myId).stop();.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179