Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve Number of JMS Message retry

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.

like image 754
rayman Avatar asked Jan 18 '11 12:01

rayman


People also ask

How do I get messages from JMS queue?

The parameter destination is a Queue or Topic object that the application has created previously. The application then uses the receive() method of the MessageConsumer object to receive a message from the destination, as shown in the following example: Message inMessage = consumer. receive(1000);

Is JMS a message queue?

JMS supports two different message delivery models: Point-to-Point (Queue destination): In this model, a message is delivered from a producer to one consumer. The messages are delivered to the destination, which is a queue, and then delivered to one of the consumers registered for the queue.

What is JMS with example?

JMS (Java Message Service) is an API that provides the facility to create, send and read messages. It provides loosely coupled, reliable and asynchronous communication. JMS is also known as a messaging service.

How many different message types are in JMS?

JMS defines six message interface types; a base message type and five subtypes.


2 Answers

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

like image 76
user568826 Avatar answered Nov 15 '22 05:11

user568826


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.

like image 37
roundrobin Avatar answered Nov 15 '22 05:11

roundrobin