wood burning stoves*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes MDB Message Acknowledgement Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "MDB Message Acknowledgement Question" Watch "MDB Message Acknowledgement Question" New topic
Author

MDB Message Acknowledgement Question

Sati Sidhu
Greenhorn

Joined: Dec 23, 2004
Posts: 6
Hi everyone,

I have discovered a discrepancy regarding message
acknowledgement using BMT message driven beans. On page 458 HF book,
it says:

"If the method throws a runtime exception, the message goes back on the queue"

According to the spec, it says:

"Message-driven beans should not attempt to use the JMS API for
message acknowledgment. Message acknowledgment is automatically
handled by the container. If the message-driven bean uses container
managed transaction demarcation, message acknowledgment is handled
automatically as a part of the transaction commit. If bean managed
transaction demarcation is used, the message receipt cannot be part of
the bean-managed transaction, and, in this case, the receipt is
acknowledged by the container."

..and according to Simon Brown's interpretation of the spec on
http://weblogs.java.net/blog/simongbrown/archive/2004/06/message_acknowl.html,
it says:

"So then, message acknowledgment is handled by the container. With
CMT, a commit or rollback will effectively acknowledge or not
acknowledge the message, but with BMT the message will always be
acknowledged. This is a subtle point but means with BMT that if the
onMessage() doesn't return successfully, the message gets acknowledged
anyway and redelivery won't occur. It seems that you have to be very
careful about implementing BMT message-driven beans!"

The Ejbplus exam simulator also backs this argument in one of the exam question anwsers.

"Since the onMessage() throws a systems exception each time it gets a message, it causes an infinite loop of delivering the message. Many application servers provide support for handing this kind of situation but if not checked, it can potentially bring down the appserver.
Also, rolling back the transaction is same as throwing a system exception because the message receipt will not be acknowledged.
Also remember that this happens only in the case of CMTs (not not for BMTs) because in case of a CMT MDB, the message acknowledgement is a part of the transaction (which gets rolled back) while in case of a BMT MDB, it is not. So even if a BMT MDB throws a system exception, the message is acknowledged.
"

Can anyone help clarify this discrepancy?

Thanks,

Sati

[ December 31, 2004: Message edited by: Sati Sidhu ]

[ December 31, 2004: Message edited by: Sati Sidhu ]

[ December 31, 2004: Message edited by: Sati Sidhu ]
[ January 01, 2005: Message edited by: Sati Sidhu ]
sandeep vaid
Greenhorn

Joined: Jul 08, 2004
Posts: 20
Hi,

As i think about it the message redilivery is only done in case of BMT if its onMessage() method dose not returns i.e. method goes in an illigalState, so in this case the SystemException and RuntimeException is only way to make the message redilivery.
That's what i know about BMT and MDB.

Thanks!!
Sandeep Vaid
 
 
subject: MDB Message Acknowledgement Question
 
Similar Threads
acknowledge-mode in MDB
JBoss Messanging: keeping message in inbox queue until it will be processed successfully - possible?
Choose Type Of Transaction with EJB (CMT VS BMT)
Doubt on Enthuware mock regarding MDBs
Need help in MDB