Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

message acknoledgement in MDBs

 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to make sure that an acknwoledgement is sent when a transaction is rolled back in case of a container managed transaction?
Thanks,
Vasu
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Section 15.4.8 of the EJB 2.0 specification states that "If the message-driven bean uses container managed transaction demarcation, message acknowledgment is handled automatically as a part of the transaction commit."
Further, in section 17.6.3.2, it says "If the onMessage method does not successfully complete or the transaction is rolled back by the Container, JMS message redelivery semantics apply."
The JMS message redelivery semantics ensures that if a failure occurs while executing the onMessage() method, the message is automatically redelivered.
The bottom line is that when you use CMT, the container is responsible for acknowledging the message. If the transaction fails, the container should redeliver the message until is goes through. Certain vendor-specific optimizations and strategies may apply, though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic