Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Bean managed transactions with MDBs in EJB 3.1

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a question regarding a statement in Ivan Krizsan's study notes on page 165, and the EJB 3.1 spec in sections 4.3.15 and 13.6.5, about reasons for using bean managed transactions. The statement I don't understand is:

Bean managed transactions "can be used with message driven beans, in order to be able to acknowledge a message even through the transaction rolls back."

I thought when BMT was used with an MDB, if the transaction rolls back, the container does not acknowledge the message. How can the message be acknowledged if the transaction rolls back?

Thanks,
Ajay
 
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to EJB 3.1 Ch 3.10.4:

If your MDB uses BMT, message receipt is not part of the transaction. If your MDB uses CMT with Transaction attribute NOT_SUPPORTED, message receipt is not part of the transaction (because there is none)

The way I understand it, is that CMT with transaction attribute REQUIRED means that the acknowledgement of your message is linked to your transaction. If your transaction rolls back, the message will be redelivered.

If you use CMT with transaction attribute NOT_SUPPORTED, or if you use BMT, the message will only be redelivered if the onMessage method throws a RuntimeException. Acknowledgement is handled by the container, but the transaction isn't. So in this case the transaction rollback will have no bearing on the redelivery of the message (with NOT_SUPPORTED because there is none, with BMT because it's not managed by the container, and the message acknowledgement is).
 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic