MDB Exception handling

hi,

I got a simple question about messagedriven beans.

My MDB is deployed with container managed transaction, attribute "required".

According to the specification, this causes the transaction to be rolled back if an exception is thrown.

Will an exception catched within the onMessage method be noticed by the container and handled so that the transaction is rolled back ? I am not sure, thats why I ask. Logically, an exception catched within the onMessage method should not be propagated to the container.

Can I roll back the message consumption action by calling setrollbackonly() in the catch block of the onMessage method ?

Best regards, Jubin

[707 byte] By [ZawarDev] at [2007-9-26 2:37:55]
# 1

You can make the container roll back the transaction by catching your application specific exception and re-throwing it as an EJBException.

In session beans you can utilise the SessionContext to setRollBackOnly() but I have never used it in MDBs. Dont see a problem with it though.

Hope that helps.

andymoose at 2007-6-29 10:08:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Hey,As MDBs are asynchronus in nature. So, u cacth that specific exception and re-throw ur own or EJBException where container will rollback the transaction.
moremahesh at 2007-6-29 10:08:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...