aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Doubt - MDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Doubt - MDB" Watch "Doubt - MDB" New topic
Author

Doubt - MDB

S.L.Narayanan
Ranch Hand

Joined: Apr 01, 2005
Posts: 431
Hi ranchers

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?.


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, NEXT--->IBM XML
pramoth suwanpech
Greenhorn

Joined: May 13, 2005
Posts: 13
You make call ctx.setRollbackOnly() ,I assume that you use CMT MDB.

You can throws only System Exception ,in spec system exception will discard bean instance.
Then the container try to deliver msg other instance from the same pool(beacuase of method not complete).


SCJP 1.4 with 96% <br />ppl in Thailand
S.L.Narayanan
Ranch Hand

Joined: Apr 01, 2005
Posts: 431
I am not asking about system exceptions...If I call ctx.setRollbackOnly() in the onMessage() method of a MDB then what will happen?.
Frank Ertl
Ranch Hand

Joined: Apr 25, 2005
Posts: 59
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.

Frank

[ October 10, 2005: Message edited by: Frank Ertl ]
[ October 10, 2005: Message edited by: Frank Ertl ]
S.L.Narayanan
Ranch Hand

Joined: Apr 01, 2005
Posts: 431
I got it. Thanks. But what will happen if my bean throws a system exception in both the cases, BMT and CMT.
Frank Ertl
Ranch Hand

Joined: Apr 25, 2005
Posts: 59
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").
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt - MDB