This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "MDB and acknowledge-mode" Watch "MDB and acknowledge-mode" New topic
Author

MDB and acknowledge-mode

A Indira
Greenhorn

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

Tks,
Indira
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:
<acknowledge-mode>Auto-acknowledge</acknowledge-mode>
or
<acknowledge-mode>Dups-ok-acknowledge</acknowledge-mode>
"


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

Joined: Aug 26, 2001
Posts: 7610
Indira,

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


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Christian D. Th. Sellberg
Greenhorn

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.

Cheers!!
Gaurav B


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

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: MDB and acknowledge-mode