how to stop redelivery of Message while error

Hi,

i have MDB in my application which runs on every 2 hours. but while run if some error like exception comes then same message is redelivered again immediately and MDB starts processing it.

could anybody please tell me how to stop this redelivery of messages.

i m facing problem becuase of processing of these redelivery of messages.

is this anything to do with acknoledge mode.

currently i have,

loQueueSession = loQueueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

please help somebody.

regards,

[573 byte] By [AshishGajabia] at [2007-11-27 1:33:41]
# 1
you can receive message and if it is with a header JMSRedelivered - ignore it.or you can use CLIENT_ACKNOWLEDGE and send acknowledgement *** soon as you get message, so if error occurs while processing, it won't be redelivered.
tomas.rimselis@mif.vu.lta at 2007-7-12 0:39:58 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

redelivery can be stopped by many ways....

wrap all your code in onMessage() in try catch block

For non-transactional clients like

[ loQueueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); ]

onMessage(Message message)

{

try {

//your code

} catch(Throwable t) {

}

}

For transactional clients

[ loQueueConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE); ]

onMessage(Message message)

{

try {

//your code

} catch(Throwable t) {

} finally {

session.commit();

}

}

Another indirect solution can be using Session.CLIENT_ACKNOWLEDGE.

Nag.

nagarjunaa at 2007-7-12 0:39:58 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Redelivary of the messages can not be stopped but

At the consumer place ,he can check the message Header field

"JMSRedelivary" field.

if it is set to true,it indicates that the message has been set to him previously and he may not acknowledge it.

by using some logic to check whether "JMSRedelivary" is set to true or not, we can stop the message

we can use message selector.

MJAGADESHa at 2007-7-12 0:39:58 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
Hi,What is non-transactional clients and transactional clients ?and diff b/w queueConnection.createQueueSession ( true , Session.AUTO_ACKNOWLEDGE )andqueueConnection.createQueueSession ( false , Session.AUTO_ACKNOWLEDGE )Thanks,Thilsen
Thilsena at 2007-7-12 0:39:58 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...