File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes MDB and acknowledge-mode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "MDB and acknowledge-mode" Watch "MDB and acknowledge-mode" New topic

MDB and acknowledge-mode

A Indira

Joined: Oct 01, 2002
Posts: 1
Can we use acknowledge-mode in the deployment descriptor when using container managed MDB?

Lionel Orellana
Ranch Hand

Joined: Mar 19, 2004
Posts: 87
According to HFEJB page 460 it is only for BMT ...

"If you DO use BMT, you have two choices for how the container sends an acknowledgement to the messaging service. The choices are:

Can anyone explain why you can't use it for CMT?
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610

Welcome to Javaranch, a friendly place for Java greenhorns

Please change your displayed name to conform to JavaRanch's Naming Policy.

You may change your displayed name here.

Thank you

[Blog] [Blogroll] [My Reviews] My Linked In
Christian D. Th. Sellberg

Joined: Apr 02, 2004
Posts: 10
Originally posted by Lionel Orellana:
According to HFEJB page 460 it is only for BMT ...

Can anyone explain why you can't use it for CMT?

I think the answer should be found in how JMS works. In JMS when you use distributed transactions (i.e. CMT) you cannot set the delivery mode, the message is acknowledged when the transaction commits successfully. That�s why you shouldn�t set acknowledge mode when using CMT.

When you use BMT the message is acknowledged when you return normally from the onMessage method, i.e. that you do not throw a RuntimeException from inside the onMessage method. The difference between Auto-acknowledge and Dups-ok-acknowledge is that with Auto-acknowledge the bean provider is guaranteed that the message is only delivered once-and-only-once with Dups-ok-acknowledge you do not have that guarantee, and the bean provider should write could that can handle that the same message is delivered more than once. Dups-ok-acknowledge is supposed to be more performance efficient than Auto-acknowledge.
[ July 13, 2004: Message edited by: Christian D. Th. Sellberg ]
Gaurav Bhatnagar
Ranch Hand

Joined: May 20, 2003
Posts: 48
Hi Indira

Good observation about the CMT Acknowledge mode..As per the EJB specs 2.0, section 15.4.8.this is what it says about the ack-mode

"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."

In English it means that let the container take care of the Acknowledge-mode as far as CMT is concerned.

Gaurav B

[SCJP 2][SCWCD1.4][SCBCD1.3]<br />First Deserve Than Desire!!
Abhishek Sharma

Joined: Oct 19, 2005
Posts: 2
hey though its a fairly old post,
but it helped me get my fundas straight on ACK mode for MDB's...

thanks a lot

SCJP 6.0 | SCBCD 5.0
I agree. Here's the link:
subject: MDB and acknowledge-mode
It's not a secret anymore!