Retrieve Number of JMS Message retry
Asked Answered
N

3

9

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.

Nunciature answered 18/1, 2011 at 12:6 Comment(0)
F
16

See javax.jms.Message.getIntProperty. Property name is "JMSXDeliveryCount".

Furfural answered 18/1, 2011 at 13:7 Comment(0)
C
1

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.

Cissy answered 19/1, 2011 at 7:13 Comment(0)
H
1

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.

Hargreaves answered 30/8, 2016 at 9:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.