dcsimg
How do I get have Message consumed from a QUEUE is CLIENT ACKNOWLEDGED if there is an error while COSUME process
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, September 23, 2002 02:04 AM




I am having a JMS QUEUE which holds certain no of records.




These messages are consumed by a LOADER object which loads the data into my Database.



Whenever my LOAD fails I want my MESSAGES to be put in QUE so that I can use it later.

Is there any way that I can do this. !!!

Re: How do I get have Message consumed from a QUEUE is CLIENT ACKNOWLEDGED if there is an error while COSUME process

Posted By:   Tom_Jenkinson  
Posted On:   Thursday, November 7, 2002 02:33 AM


If I understand your problem correctly, you sound as if your on the right line with using CLIENT_ACKNOWLEDGE mode.

Basically what you can do is create the LOADER QueueReceiver with a session that is using CLIENT_ACKNOWLEDGE mode.

Sessions created in this mode can make use of the recover method of a session that will place unacknowledged messages back into the queue.

Check out this link for more info on recover:

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/Session.html#recover()

See the following for a brief example:

{
// Receive the message
Message message = queueReceiver.receive();

try
{
// Try to handle the load to the database
databaseHandler.loadMessage(message);
// Acknowledge the message if succesful
message.acknowledge();
}
catch (Exception e)
{
// If you cannot load the message then invoked
// recover on the receivers session
queueReceiversSession.recover();
}
}

Hope this helps you,

Tom Jenkinson
Arjuna Technologies Limited
About | Sitemap | Contact