Jms error handler: receives a callback only when jms refuses

I am using spring-jms with active mq.

I have an ErrorHandler customizer that gets a callback every time a jms message delivery failure fails, that is, the method that processes the message throws an exception instead of returning gracefully.

However, my jms are set up to retry several times until the jms delivery is finally completed. And my callback is notified of all failures.

What I want is a listener who receives a notification only when all retries finally fail. The motivation is to bring the problem to the attention of the administrator. But I do not want false notifications in the admin console.

 <bean abstract="true" id="abstractDestinationListener" class="org.springframework.jms.listener.DefaultMessageListenerContainer"> <property name="connectionFactory" ref="jmsFactory" /> <property name="errorHandler" ref="destinationErrorHandler"/> <property name="sessionTransacted" value="true"/> </bean> 
+4
source share
2 answers

What you might think is to use a dead letter queue for each recipient ( individualDeadLetterStrategy - https://activemq.apache.org/message-redelivery-and-dlq-handling.html ) for the items in question, When the maximum is reached re-delivery account, message is transferred to DLQ. You can then configure the user in this queue using a listener that sends an email to the administrator.

Another way to do this could be to wrap your listener with a try-catch and throw any exceptions only if message.getIntProperty("JMSXDeliveryCount") < MAX_REDELIVERY_COUNT and email the administrator otherwise. However, this option means that you set the forwarding limit in two places - broker configuration and code.

+2
source

if you need finer-scale management / flexibility / routing with JMS messaging / handling, you should just use Apache Camel error handling ...

0
source

All Articles