There is a message property named JMSXDeliveryCount that indicates how many times the message has been delivered. Section 3.5.11 of the JMS 2. 0 spec says this about JMSXDeliveryCount:
When a client receives a message the mandatory JMS-defined message
property JMSXDeliveryCount will be set to the number of times the
message has been delivered. The first time a message is received it
will be set to 1, so a value of 2 or more means the message has been
redelivered.
If the JMSRedelivered message header value is set then the
JMSXDeliveryCount property must always be 2 or more. See section
3.4.7 “JMSRedelivered” for more information about the JMSRedelivered message header,
The purpose of the JMSXDeliveryCount property is to allow consuming
applications to identify whether a particular message is being
repeatedly redelivered and take appropriate action.
The value of the JMSXDeliveryCount property is not guaranteed to be
exactly correct. The JMS provider is not expected to persist this
value to ensure that its value is not lost in the event of a failure.