'How to constantly confirm the status of a JMS consumer
I have a Spring Boot microservice using the JMS API to consume messages from an ActiveMQ queue.
My current issue is that the microservice often loses its subscription as consumer. I'd like to create a logic to constantly check the status of the consumer and apply a retry strategy when lost.
Is there any way to confirm the status of a subscription as a consumer or to access the number of consumers per queue?
It's worth noting that the microservice serves as consumer and not a producer.
Solution 1:[1]
If you're consuming the message synchronously (e.g. via javax.jms.MessageConsumer.receive()) and there is a problem with the connection then an exception should be thrown. When an exception is thrown you can implement your retry strategy as appropriate.
If you are consuming messages asynchronously (i.e. using a MessageListener) then you should set an ExceptionListener on the javax.jms.Connection to catch any exception and implement your retry strategy as appropriate.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Justin Bertram |
