The JMS 1.0.2 spec is pretty clear about it (in my opinion). In section
4.4.13 in the AUTO_ACKNOWLEDGE point:

"With this option, the session automatically acknowledges a client's receipt
of a message when it has either successfully returned from a call to receive
or the MessageListener it has called to process the message successfully
returns."

So when you call receive, the message has been acknowledge when you get a
hold of it. When you have a message listener, it won't be acknowledged until
onMessage successfully returns.

This means that with AUTO_ACKNOWLEDGE a crash can cause one duplicate
message if you have a message listener, and you can loose one message
silently if you use synchronous receive.

However, for XA the session is transacted, which is a different acknowledge
mode than AUTO_ACKNOWLEDGE. Here, ack's are done using the session's
XAResource.

Best regards,
Bjarne.

----- Original Message -----
From: "Richard Monson-Haefel" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, July 21, 2001 9:37 AM
Subject: MDBs & message auto-acknowledgment


> The EJB 2.0 specification doesn't say when a message is acknowledge with
> Auto-acknowledgment in BMT message-driven beans (MDB).  This is somewhat
> understandable since JMS itself is somewhat ambiguous about the exact
> timing of AUTO_ACKNOWLEDGMENT mode.  However, it makes a big difference
> in EJB 2.0  if the message is acknowledged before the message is
> delegated to the MDB instance or after.  With Auto-acknowledgment, I
> would make the assumption that the message is acknowledged  before
> delegating the message to the client, or shortly there after regardless
> of the out come of the onMessage() method (normal return vs. exception
> thrown).
>
> It would be better, however, if it occurred after the successful
> completion of the onMessage() method to allow redelivery of the message
> in the advent of a failure while handling the message.  In other words,
> if the MDB throws an exception from the onMessage() method, the receipt
> of the message should not be acknowledged by the EJB container.  In BMT
> MDB where message acknowledgment is not a part of the transaction commit
> processes, a failure to acknowledge the message would allow it to be
> redelivered and not lost. This is also true of container-managed
> transactions where the transaction attribute is NotSupported.  This is
> something that should be clarified in the specification or at least
> addressed.
>
> I would be interested in hearing Sun Microsystems comments on this as
> well as the vendors.  How are vendors handling this?  How does the EJB
> 2.0 spec team feel it should be handled?
>
> Thanks,
>
> Richard
> --
> Richard Monson-Haefel
> Author of Enterprise JavaBeans, 2nd Edition  (O'Reilly 2000)
> Co-Author of Java Message Service (O'Reilly 2000)
> http://www.jMiddleware.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to