Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Meaning of Transaction-type under ejb-jar.xml is set to Container ??

 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .


 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,

 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 .

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic