Ian McCallion wrote:

> Richard Monson-Haefel wrote:
> >
> > 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.
>
> Richard,
>
> I think you are muddling two concepts here, "acknowledgement", and "guaranteed
> delivery".
>
> An acknowledgement is an encouraging information mesage - no more. It's a bit
> like an email from Amazon saying your book order was delivered to your favorite
> aunt.
>
> Guaranteed delivery is a messaging feature that means that the message will not
> be lost. It uses safe store and forward techniques to get the message to the
> target application and transaction processing to ensure the message is processed
> once only. Poisoned messages are a difficulty with guaranteed delivery. A
> poisoned message is one that causes the application to rollback each time it is
> retried. Typically messages are retried a few times then put to one side for
> examination by people rather than programs.
>
> You should not try to implement your own guaranteed delivery by using lack of an
> acknowledgement as a trigger to resend the message, just as you should not
> resubmit your book order just because you have not received an email from Amazon
> by the time of your aunt's birthday!
>
> cheers... Ian
>

Hi Ian,

Thanks for the in-depth response.  Fortunately, I'm not confused about the
difference between "guaranteed messaging" and acknowledgment. I think you will agree
that guaranteed messaging results from the a combination of things, which including
transaction management and message persistence. Acknowledgment, this cause, is tied
to the transaction management.

However, not all MDBs will be transacted so in those cases acknowledgment is our
best bet for predicting when re-delivery may occur. Understanding that
acknowledgment occurs after the MessageListener.onMessage() returns, rather then
before or during, is important to understand the risks associated with failures of
the MDB while consuming a non transacted message. I agree that acknowledgment itself
is not reliable (not as reliable as guaranteed messaging) but it is an import aspect
of JMS and needs to be explained accurately, which is why I needed a clarification
as to when messages are acknowledged in a non transacted scenario. Thanks to you and
others this question has been answered to my satisfaction and need not be pursued
any longer.

For those who are interested you may read the latest draft of Chapter 13, which
covers JMS and message-driven beans. This chapter doesn't address the above topic
yet (TBD) but its is otherwise complete. Feedback from readers is welcome.

You can download Chapter 13: Message-Driven Beans from O'Reilly's web site:
http://oreilly.techrev.org/

Thanks again!

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