Something struck me as a bit strange with the AUTO_ACKNOWLEDGE and MessageListeners as
defined in the JMS spec.
It has always been my understanding that using AUTO_ACKNOWLEDGE gives a "at most
once" delivery guarantee.
You get a "at most once" guarantee because (with receive() at least) the message
is acknowledged *before* the call to receive() has returned, so if failure occurs between
acking and giving you the message it is effectively lost you - you didn't receive it,
but you could never get it more than once.
However when using a MessageListener breaks this breaks down. For a MessageListener,
according to the JMS spec, if you are using AUTO_ACKNOWLEDGE then the message should be
acked *after* the onMessage has finished executing.
This means if a failure occurs right at the end of the onMessage but before the message is
acked, it could be received again - i.e. you could get duplicates, and the "at most
once" delivery guarantee is lost.
In order to maintain "at most once" semantics the message should be acked before
onMessage is called.
Is this just a stupidity in the JMS spec or can you think of any reason it was done this
way?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4001281#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...