activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Timothy Bish (Resolved) (JIRA)" <jira+amq...@apache.org>
Subject [jira] [Resolved] (AMQNET-335) MessageConsumer does not Rollback on Exception
Date Sat, 12 Nov 2011 21:07:51 GMT

     [ https://issues.apache.org/jira/browse/AMQNET-335?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Timothy Bish resolved AMQNET-335.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 1.6.0
                   1.5.2

Fix and a test added to trunk and 1.5.x
                
> MessageConsumer does not Rollback on Exception
> ----------------------------------------------
>
>                 Key: AMQNET-335
>                 URL: https://issues.apache.org/jira/browse/AMQNET-335
>             Project: ActiveMQ .Net
>          Issue Type: Bug
>          Components: ActiveMQ
>            Reporter: Rasitha Wijesinghe
>            Assignee: Timothy Bish
>            Priority: Minor
>             Fix For: 1.5.2, 1.6.0
>
>
> For modes of AutoAcknowledgeEach, AutoAcknowledgeBatch & IndividualAcknowledge, Dispatch
method is missing a call to Rollback() when listener throws an exception.
> Java version is doing this correctly but the .net version does not have that call.
> http://activemq.2283324.n4.nabble.com/Apache-NMS-ActiveMQ-MessageConsumer-bug-td3566206.html
> Because of this, messages don't get properly nacked nor will they get into a DLQ correctly.
> Java Code:
> {code:java}
> } catch (RuntimeException e) {
> 	LOG.error(getConsumerId() + " Exception while processing message: " + md.getMessage().getMessageId(),
e);
> 	if (isAutoAcknowledgeBatch() || isAutoAcknowledgeEach() || session.isIndividualAcknowledge())
{
> 	    // schedual redelivery and possible dlq processing
> 	    md.setRollbackCause(e);
> 	    rollback();
> 	} else {
> 	    // Transacted or Client ack: Deliver the
> 	    // next message.
> 	    afterMessageIsConsumed(md, false);
> 	}
>     }
> {code}
> .Net version:
> {code}
> catch(Exception e)
> {
> 	if(IsAutoAcknowledgeBatch || IsAutoAcknowledgeEach || IsIndividualAcknowledge)
> 	{
> 		// Redeliver the message
> 	}
> 	else
> 	{
> 		// Transacted or Client ack: Deliver the next message.
> 		this.AfterMessageIsConsumed(dispatch, false);
> 	}
> 	Tracer.Error(this.info.ConsumerId + " Exception while processing message: " + e);
> 	// If aborted we stop the abort here and let normal processing resume.
> 	// This allows the session to shutdown normally and ack all messages
> 	// that have outstanding acks in this consumer.
> 	if( (Thread.CurrentThread.ThreadState & ThreadState.AbortRequested) == ThreadState.AbortRequested)
> 	{
> 		Thread.ResetAbort();
> 	}
> }
> {code}
> Think the solution is to call Rollback().
> {code}
> catch(Exception e)
> {
> 	if(IsAutoAcknowledgeBatch || IsAutoAcknowledgeEach || IsIndividualAcknowledge)
> 	{
> 	    // Redeliver the message
> 	    Rollback(); // this takes care of checking the RedeliveryCounter and nacking when
necessary
> 	}
> 	else
> 	{
> 		// Transacted or Client ack: Deliver the next message.
> 		this.AfterMessageIsConsumed(dispatch, false);
> 	}
> 	Tracer.Error(this.info.ConsumerId + " Exception while processing message: " + e);
> 	// If aborted we stop the abort here and let normal processing resume.
> 	// This allows the session to shutdown normally and ack all messages
> 	// that have outstanding acks in this consumer.
> 	if( (Thread.CurrentThread.ThreadState & ThreadState.AbortRequested) == ThreadState.AbortRequested)
> 	{
> 		Thread.ResetAbort();
> 	}
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message