This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a doubt on MDBs...If an application exception is caught on the onMessage method of a MDB and I found that it is not possible to continue there after....So in the catch block I call ctx.setRollbackOnly() and re-throw the exception. Now what will happen?...Will the container try to deliver the message again to some other instance from the same pool or will the container simply discard the instance and discard the message?.
Well, if you use ctx.setRollbackOnly() I guess you are using CMT. With CMT the Message will be redelievered again and again and again... That happens because the whole transaction (including the receipt of the message from the Queue) ist rolled back what means that the message is put back on the Queue.
[ October 10, 2005: Message edited by: Frank Ertl ] [ October 10, 2005: Message edited by: Frank Ertl ]
Joined: Apr 01, 2005
I got it. Thanks. But what will happen if my bean throws a system exception in both the cases, BMT and CMT.
Joined: Apr 25, 2005
If you use CMT the bean instance will be discarded and the transaction will be rolled back unless you specify the transaction attribute to "NotSupported". With bean managed persistence the bean instance will be discarded, too, but what happens to the message depends on your acknowlegement policy ("auto-acknowledge" vs. "dups-ok-acknowledge").