users@glassfish.java.net

MDB and endpointExceptionRedeliveryAttempts + infinite redelivery loop

From: janne postilista <jannepostilistat_at_gmail.com>
Date: Fri, 27 Aug 2010 10:38:59 +0300

Hi,

 my MDB calls other (session) EJBs. In some cases, EJB call X fails,
sets transaction to rollback, and my MDB's onMessage ends normally (it
does not throw exceptions). In this case, I always get infinite loop
while my MDB retries the same message again and again. Setting
endpointExceptionRedeliveryAttempts to the MDB has no effect in this
case.

@MessageDriven(mappedName = "jms/test/zzz", activationConfig =  {
       @ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Queue"),
       @ActivationConfigProperty(propertyName =
"sendUndeliverableMsgsToDMQ", propertyValue = "true"),
       @ActivationConfigProperty(propertyName =
"endpointExceptionRedeliveryAttempts", propertyValue = "0")
})

=> infinite retries when transaction is set to rolled back but no
exception is thrown from onMessage.

QUESTION: is this as it should be? Is there some design rules which
says that "MDB should always throw (unchecked?) exception if
transaction fails"? Or should endpointExceptionRedeliveryAttempts
config also affect the cases when MDB does not throw exceptions (as I
would have thought)?

Of course, I can alter the design and even add

if (transaction.isRolledback()) {
 throw new NullPointerException("dummy exception to stop looping eternally");
}

to my MDB.