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,
# 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.
# 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.
# 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.
# 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