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
posted
0
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
posted
0
Indira,
Welcome to Javaranch, a friendly place for Java greenhorns
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
posted
0
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
posted
0
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: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.