| Author |
Meaning of Transaction-type under ejb-jar.xml is set to Container ??
|
Ravi Kiran Va
Ranch Hand
Joined: Apr 18, 2009
Posts: 2234
|
|
Hi ,
We are using MessageDrivenBeans and on to its onMessage Method we are using the try catch and finally blocks .
(As to my knowledge this means that the transactions are handled by the developer )
But when i see on to the ejb-jar.xml the transaction-type is set to Container .
Please throw me some light as who is handling the transactions in this case ??
Thanks in advance .
|
Save India From Corruption - Anna Hazare.
|
 |
Christian Gossart
Ranch Hand
Joined: Mar 13, 2008
Posts: 34
|
|
Hi Ravi,
If you have in your deployment descriptor, this will override the corresponding annotation for the enterprise bean. So in your case, the EJB container is handling the transaction, even if your MDB is annotated with A transaction is opened by the container immediately before any call to onMessage, and commited/closed immediately after, unless a system exception is thrown, or the setRollbackOnly method is called on the EJBContext.
Using try/catch/finally does not imply the transaction is being handled by the developer, only that you're dealing with exception coming from your business layer (or anything invoked by your MDB).
To handle yourself the transaction, you have to remove the ejb-jar.xml fragment for this MDB (or set the transaction type to BEAN), and use the TransactionManager interface to begin(), commit() or rollback() the transaction in your code.
You'll find more information on transaction management there: http://java.sun.com/javaee/5/docs/tutorial/doc/bncii.html
Regards,
|
Christian Gossart
|
 |
ramprasad madathil
Ranch Hand
Joined: Jan 24, 2005
Posts: 489
|
|
Ravi Kiran V wrote:Hi ,
We are using MessageDrivenBeans and on to its onMessage Method we are using the try catch and finally blocks .
(As to my knowledge this means that the transactions are handled by the developer )
Why do you think so?
But when i see on to the ejb-jar.xml the transaction-type is set to Container .
Please throw me some light as who is handling the transactions in this case ??
The container.
ram.
|
 |
Ravi Kiran Va
Ranch Hand
Joined: Apr 18, 2009
Posts: 2234
|
|
Using try/catch/finally does not imply the transaction is being handled by the developer, only that you're dealing with exception coming from your business layer (or anything invoked by your MDB).
Thanks for this line Christian Gossart .It was indeed very helpful .
|
 |
 |
|
|
subject: Meaning of Transaction-type under ejb-jar.xml is set to Container ??
|
|
|