Reputation: 21596
I am using JMS Queue, and MDB which listen to it. I have a retry mechanism, so when exception is being thrown a rollback to the transaction will occur and the operation will re-executed/
I would like to achieve the Message_retry_number, each time "onMessage" being executed, so I can write the current execution retry number. I heard I can retrieve it through the Header of the message object, but couldn't find anything in the properties or in the net.
anyone has any clue?
Thanks, ray.
Upvotes: 9
Views: 8468
Reputation: 31
From oracle tutorial [https://docs.oracle.com/javaee/7/tutorial/jms-concepts003.htm#BNCEH] section 45.3.7.2 Message Properties:
The JMS API provides some predefined property names that begin with JMSX. A JMS provider is required to implement only one of these, JMSXDeliveryCount (which specifies the number of times a message has been delivered); the rest are optional. The use of these predefined properties or of user-defined properties in applications is optional.
the JMSXDeliveryCount implementation is required, and it will contain the information you need.
Upvotes: 1
Reputation: 399
The only standard way to do this is be having a look at the JMSXDeliveryCount property. However you should be aware that the JMS specification states that JMS defined properties (those starting with JMSX) are optional - so it depends on your specific provider whether this property is supported, and set in every case.
Upvotes: 1
Reputation: 601
See javax.jms.Message.getIntProperty. Property name is "JMSXDeliveryCount".
Upvotes: 16