How to stop MDB retry invocation during System Exception
posted 5 years ago
I'm using CMT MDB to consume the message from Websphere MQ and it is deployed in Websphere application server.
Once the message is received by MDB, MDB delegates the message to application to process it further. If there is any system exception (example: Data base exception), seems, the transaction is rolled back and MQ keeps trying to send the same message. But I do not want MQ to resending the message to MDB if there an system exception occurred in the application since I do not want to process the message again if it is not processed in the first attempt.
What is the best approach to stop the retry ? Can this be handled in MDB or something needs to be done in MQ or WAS ?
Catch java.lang.Exception and allow the method to terminate normally.
If that is not possible due to some reason, check if your MessageProvider sets the 'JMSRedelivered' flag for messages that are redelivered. Most servers do. In which case, just check if it's a redelivered message and return normally.