[ https://issues.apache.org/jira/browse/AMQ-5445?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14219502#comment-14219502 ]
Sergiy Barlabanov edited comment on AMQ-5445 at 11/20/14 3:45 PM: ------------------------------------------------------------------ And the patch would be I guess to extend the catch {} clause in org.apache.activemq.ActiveMQSession#run and make it look something like this: {code} } catch (Throwable e) { LOG.error("error dispatching message: ", e); // A problem while invoking the MessageListener does not // in general indicate a problem with the connection to the broker, i.e. // it will usually be sufficient to let the afterDelivery() method either // commit or roll back in order to deal with the exception. // However, we notify any registered client internal exception listener // of the problem. connection.onClientInternalException(e); if (transactionContext != null && transactionContext.isInLocalTransaction()) { try { rollback(); } catch (Throwable rollbackException) { LOG.error("Error while trying to rollback the session", rollbackException); connection.onClientInternalException(rollbackException); } } {code} or may be there is another way to let org.apache.activemq.ra.ServerSessionImpl#afterDelivery know that it has to rollback instead of committing. was (Author: barlabanov): And the patch would be I guess to extend the catch {} clause in org.apache.activemq.ActiveMQSession#run and make it look something like this: } catch (Throwable e) { LOG.error("error dispatching message: ", e); // A problem while invoking the MessageListener does not // in general indicate a problem with the connection to the broker, i.e. // it will usually be sufficient to let the afterDelivery() method either // commit or roll back in order to deal with the exception. // However, we notify any registered client internal exception listener // of the problem. connection.onClientInternalException(e); if (transactionContext != null && transactionContext.isInLocalTransaction()) { try { rollback(); } catch (Throwable rollbackException) { LOG.error("Error while trying to rollback the session", rollbackException); connection.onClientInternalException(rollbackException); } } or may be there is another way to let org.apache.activemq.ra.ServerSessionImpl#afterDelivery know that it has to rollback instead of committing. > Message acknowledged despite of an exception thrown by a message driven bean > ---------------------------------------------------------------------------- > > Key: AMQ-5445 > URL: https://issues.apache.org/jira/browse/AMQ-5445 > Project: ActiveMQ > Issue Type: Bug > Components: JCA Container > Affects Versions: 5.10.0 > Environment: Windows, Glassfish 3.1.2.2 with AMQ RAR, ActiveMQ 5.10.0 > running standalone. > Reporter: Sergiy Barlabanov > > When a Glassfish server is going down, messages being currently delivered to > a MDB, are acknowledge with the message coming from > org.apache.activemq.ra.ServerSessionImpl: > Local transaction had not been commited. Commiting now. > Having analyzed the problem, we discovered, that when Glassfish is going down > the method endpoint#beforeDelivery > (org.apache.activemq.ra.ServerSessionImpl#beforeDelivery) does not start an > XA transaction. So ActiveMQ starts a local transaction in > org.apache.activemq.ActiveMQSession#doStartTransaction. After that > ActiveMQSession#run tries to call messageListener.onMessage() and it fails > with an exception. Exception is handled in ActiveMQSession#run, but is not > propagated to org.apache.activemq.ra.ServerSessionImpl#afterDelivery. And in > org.apache.activemq.ra.ServerSessionImpl#afterDelivery there is finally {} > clause, which commits the session if there is local transaction (and there is > one - see above) despite the exception occurred before. > This last commit seems to be inappropriate. In case of a transaction (local > or not) the corresponding message may not be acknowledged - it must be > rollbacked (no session commit). -- This message was sent by Atlassian JIRA (v6.3.4#6332)