• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

MDB Message Acknowledgement Question

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



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

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.

Sandeep Vaid
    Bookmark Topic Watch Topic
  • New Topic