Return-Path: X-Original-To: apmail-activemq-dev-archive@www.apache.org Delivered-To: apmail-activemq-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2D82A4220 for ; Thu, 7 Jul 2011 23:22:42 +0000 (UTC) Received: (qmail 40273 invoked by uid 500); 7 Jul 2011 23:22:41 -0000 Delivered-To: apmail-activemq-dev-archive@activemq.apache.org Received: (qmail 39725 invoked by uid 500); 7 Jul 2011 23:22:41 -0000 Mailing-List: contact dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list dev@activemq.apache.org Received: (qmail 39715 invoked by uid 99); 7 Jul 2011 23:22:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jul 2011 23:22:40 +0000 X-ASF-Spam-Status: No, hits=-1998.7 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD,URI_HEX X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jul 2011 23:22:39 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id AFEB74CBC6 for ; Thu, 7 Jul 2011 23:22:18 +0000 (UTC) Date: Thu, 7 Jul 2011 23:22:18 +0000 (UTC) From: "Rasitha Wijesinghe (JIRA)" To: dev@activemq.apache.org Message-ID: <2079987865.9502.1310080938717.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1328253107.9486.1310080578431.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (AMQNET-335) MessageConsumer does not Rollback on Exception MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AMQNET-335?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Rasitha Wijesinghe updated AMQNET-335: -------------------------------------- Description: 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} was: 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://permalink.gmane.org/gmane.comp.java.activemq.user/30901 Because of this, messages don't get properly nacked nor will they get into a DLQ correctly. Java Code: } 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); } } .Net version: 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(); } } Think the solution is to call Rollback(). 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(); } } > 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: Jim Gomes > Priority: Minor > > 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. For more information on JIRA, see: http://www.atlassian.com/software/jira