• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Message Retry and adding poison message to DLQ in Spring JMS And ActiveMQ

 
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a requirement to load messages from two queues and i am using ActiveMQ, I have to implement the Retry mechanism in case of any error or network or application server failure and load back into the same Queue. Also, I want to load any poison messages to DLQ.

Please let me know if I can acheive these through Spring JMS. Also, please advise some good examples to accomplish this task. I checked Spring JMS documentation and have not much details in that.
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will want to configure your connection factory appropriately.
http://activemq.apache.org/redelivery-policy.html


You can use transactions that fail to cause the rollback/retry. There are a number of different strategies here, and of course the best way to handle this comes down to your requirements. I still think this article is an awesome read regarding that:
http://www.javaworld.com/article/2077963/open-source-tools/distributed-transactions-in-spring--with-and-without-xa.html

Lastly if Spring JMS support is not cutting it you will find more advanced integration techniques supported in the Spring Integration project.
http://docs.spring.io/spring-integration/reference/pdf/spring-integration-reference.pdf
 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried doing the same. But my poison messages are not getting into DLQ. Here is my configuration xml and Listener/Consumer. Can you please review and advise if any error or mistakes in my code.






Also kindly provide me the answers for this questions

A) I am using activemq 5.5 and in the redelivery policy is not accepting the queue property (see **** comment in XML file). So I tried creating DLQ manually in admin server and re-run the Listener, the poison messages are not getting queued there. Please advise?

B) Should I need to create the DLQ explicity from the code or does activemq creates after error message is retried after some time?
 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got the fix. I was catching the exception in catch block which I understood should not be. If I throw the exception from Catch Block, the message is going to DLQ after respective retries.

Please advise how could the below requirements be accomplished through ActiveMQ and Spring JMS.

A) I want to push the messages into DLQ only when respective exception occurs. Currently as per my understanding, any exceptions thrown from Message Listeners are moved to DLQ after specified retry parameters.
B) Could I control the like No-Retry for custom exceptions. For example, if there is an Instance of MyException class thrown, I should not retry those messages such that it should not even go to DLQ.



 
I've been selected to go to the moon! All thanks to this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic