Return-Path: Delivered-To: apmail-activemq-dev-archive@www.apache.org Received: (qmail 40109 invoked from network); 31 Mar 2011 17:04:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 31 Mar 2011 17:04:45 -0000 Received: (qmail 37398 invoked by uid 500); 31 Mar 2011 17:04:44 -0000 Delivered-To: apmail-activemq-dev-archive@activemq.apache.org Received: (qmail 37373 invoked by uid 500); 31 Mar 2011 17:04:44 -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 37365 invoked by uid 99); 31 Mar 2011 17:04:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Mar 2011 17:04:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD 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, 31 Mar 2011 17:04:43 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 52FF28CF5F for ; Thu, 31 Mar 2011 17:04:06 +0000 (UTC) Date: Thu, 31 Mar 2011 17:04:06 +0000 (UTC) From: "Jim Gomes (JIRA)" To: dev@activemq.apache.org Message-ID: <297217402.24833.1301591046336.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <823190383.22583.1301527745731.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback 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-323?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jim Gomes updated AMQNET-323: ----------------------------- Description: When TimeToLive expires while a listener is in a redeliver loop, the redelivery never stops. The following unit tests show this. The first unit test uses Receive and it works fine. The second uses a listener and it fails. I added these tests to AMQRedeliveryPolicyTests {code} [Test] public void TestNornalRedeliveryPolicyOnRollbackUntilTimeToLive() { using(Connection connection = (Connection) CreateConnection()) { IRedeliveryPolicy policy = connection.RedeliveryPolicy; policy.MaximumRedeliveries = -1; policy.InitialRedeliveryDelay = 500; policy.UseExponentialBackOff = false; connection.Start(); ISession session = connection.CreateSession(AcknowledgementMode.Transactional); IDestination destination = session.CreateTemporaryQueue(); IMessageProducer producer = session.CreateProducer(destination); IMessageConsumer consumer = session.CreateConsumer(destination); // Send the messages ITextMessage textMessage = session.CreateTextMessage("1st"); textMessage.NMSTimeToLive = TimeSpan.FromMilliseconds(800.0); producer.Send(textMessage); session.Commit(); ITextMessage m; m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(1000)); Assert.IsNotNull(m); Assert.AreEqual("1st", m.Text); session.Rollback(); // No delay on first Rollback.. m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(100)); Assert.IsNotNull(m); session.Rollback(); // Show subsequent re-delivery delay is incrementing. m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(100)); Assert.IsNull(m); m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(700)); Assert.IsNotNull(m); Assert.AreEqual("1st", m.Text); session.Rollback(); // The message gets redelivered after 500 ms every time since // we are not using exponential backoff. m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(700)); Assert.IsNull(m); } } [Test] public void TestNornalRedeliveryPolicyOnRollbackUntilTimeToLiveCallback() { using(Connection connection = (Connection) CreateConnection()) { IRedeliveryPolicy policy = connection.RedeliveryPolicy; policy.MaximumRedeliveries = -1; policy.InitialRedeliveryDelay = 500; policy.UseExponentialBackOff = false; connection.Start(); ISession session = connection.CreateSession(AcknowledgementMode.Transactional); IDestination destination = session.CreateTemporaryQueue(); IMessageProducer producer = session.CreateProducer(destination); IMessageConsumer consumer = session.CreateConsumer(destination); CallbackClass cc = new CallbackClass(session); consumer.Listener += new MessageListener(cc.consumer_Listener); // Send the messages ITextMessage textMessage = session.CreateTextMessage("1st"); textMessage.NMSTimeToLive = TimeSpan.FromMilliseconds(800.0); producer.Send(textMessage); session.Commit(); // sends normal message, then immediate retry, then retry after 500 ms, then expire. Thread.Sleep(2000); Assert.AreEqual(3, cc.numReceived); } } class CallbackClass { private ISession session; public int numReceived = 0; public CallbackClass(ISession session) { this.session = session; } public void consumer_Listener(IMessage message) { numReceived++; ITextMessage m = message as ITextMessage; Assert.IsNotNull(m); Assert.AreEqual("1st", m.Text); session.Rollback(); } } {code} was: When TimeToLive expires while a listener is in a redeliver loop, the redelivery never stops. The following unit tests show this. The first unit test uses Receive and it works fine. The second uses a listener and it fails. I added these tests to AMQRedeliveryPolicyTests [Test] public void TestNornalRedeliveryPolicyOnRollbackUntilTimeToLive() { using(Connection connection = (Connection) CreateConnection()) { IRedeliveryPolicy policy = connection.RedeliveryPolicy; policy.MaximumRedeliveries = -1; policy.InitialRedeliveryDelay = 500; policy.UseExponentialBackOff = false; connection.Start(); ISession session = connection.CreateSession(AcknowledgementMode.Transactional); IDestination destination = session.CreateTemporaryQueue(); IMessageProducer producer = session.CreateProducer(destination); IMessageConsumer consumer = session.CreateConsumer(destination); // Send the messages ITextMessage textMessage = session.CreateTextMessage("1st"); textMessage.NMSTimeToLive = TimeSpan.FromMilliseconds(800.0); producer.Send(textMessage); session.Commit(); ITextMessage m; m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(1000)); Assert.IsNotNull(m); Assert.AreEqual("1st", m.Text); session.Rollback(); // No delay on first Rollback.. m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(100)); Assert.IsNotNull(m); session.Rollback(); // Show subsequent re-delivery delay is incrementing. m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(100)); Assert.IsNull(m); m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(700)); Assert.IsNotNull(m); Assert.AreEqual("1st", m.Text); session.Rollback(); // The message gets redelivered after 500 ms every time since // we are not using exponential backoff. m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(700)); Assert.IsNull(m); } } [Test] public void TestNornalRedeliveryPolicyOnRollbackUntilTimeToLiveCallback() { using(Connection connection = (Connection) CreateConnection()) { IRedeliveryPolicy policy = connection.RedeliveryPolicy; policy.MaximumRedeliveries = -1; policy.InitialRedeliveryDelay = 500; policy.UseExponentialBackOff = false; connection.Start(); ISession session = connection.CreateSession(AcknowledgementMode.Transactional); IDestination destination = session.CreateTemporaryQueue(); IMessageProducer producer = session.CreateProducer(destination); IMessageConsumer consumer = session.CreateConsumer(destination); CallbackClass cc = new CallbackClass(session); consumer.Listener += new MessageListener(cc.consumer_Listener); // Send the messages ITextMessage textMessage = session.CreateTextMessage("1st"); textMessage.NMSTimeToLive = TimeSpan.FromMilliseconds(800.0); producer.Send(textMessage); session.Commit(); // sends normal message, then immediate retry, then retry after 500 ms, then expire. Thread.Sleep(2000); Assert.AreEqual(3, cc.numReceived); } } class CallbackClass { private ISession session; public int numReceived = 0; public CallbackClass(ISession session) { this.session = session; } public void consumer_Listener(IMessage message) { numReceived++; ITextMessage m = message as ITextMessage; Assert.IsNotNull(m); Assert.AreEqual("1st", m.Text); session.Rollback(); } } > NMS Client does not respect TimeToLive with Listener callback > ------------------------------------------------------------- > > Key: AMQNET-323 > URL: https://issues.apache.org/jira/browse/AMQNET-323 > Project: ActiveMQ .Net > Issue Type: Bug > Components: ActiveMQ, NMS > Affects Versions: 1.5.0 > Environment: Windows 7 > Reporter: Matthew Good > Assignee: Jim Gomes > Attachments: TtlUnitTest.txt > > > When TimeToLive expires while a listener is in a redeliver loop, the redelivery never stops. The following unit tests show this. The first unit test uses Receive and it works fine. The second uses a listener and it fails. > I added these tests to AMQRedeliveryPolicyTests > {code} > [Test] > public void TestNornalRedeliveryPolicyOnRollbackUntilTimeToLive() > { > using(Connection connection = (Connection) CreateConnection()) > { > IRedeliveryPolicy policy = connection.RedeliveryPolicy; > policy.MaximumRedeliveries = -1; > policy.InitialRedeliveryDelay = 500; > policy.UseExponentialBackOff = false; > connection.Start(); > ISession session = connection.CreateSession(AcknowledgementMode.Transactional); > IDestination destination = session.CreateTemporaryQueue(); > IMessageProducer producer = session.CreateProducer(destination); > IMessageConsumer consumer = session.CreateConsumer(destination); > // Send the messages > ITextMessage textMessage = session.CreateTextMessage("1st"); > textMessage.NMSTimeToLive = TimeSpan.FromMilliseconds(800.0); > producer.Send(textMessage); > session.Commit(); > ITextMessage m; > m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(1000)); > Assert.IsNotNull(m); > Assert.AreEqual("1st", m.Text); > session.Rollback(); > // No delay on first Rollback.. > m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(100)); > Assert.IsNotNull(m); > session.Rollback(); > // Show subsequent re-delivery delay is incrementing. > m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(100)); > Assert.IsNull(m); > m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(700)); > Assert.IsNotNull(m); > Assert.AreEqual("1st", m.Text); > session.Rollback(); > // The message gets redelivered after 500 ms every time since > // we are not using exponential backoff. > m = (ITextMessage)consumer.Receive(TimeSpan.FromMilliseconds(700)); > Assert.IsNull(m); > > } > } > [Test] > public void TestNornalRedeliveryPolicyOnRollbackUntilTimeToLiveCallback() > { > using(Connection connection = (Connection) CreateConnection()) > { > IRedeliveryPolicy policy = connection.RedeliveryPolicy; > policy.MaximumRedeliveries = -1; > policy.InitialRedeliveryDelay = 500; > policy.UseExponentialBackOff = false; > connection.Start(); > ISession session = connection.CreateSession(AcknowledgementMode.Transactional); > IDestination destination = session.CreateTemporaryQueue(); > IMessageProducer producer = session.CreateProducer(destination); > IMessageConsumer consumer = session.CreateConsumer(destination); > CallbackClass cc = new CallbackClass(session); > consumer.Listener += new MessageListener(cc.consumer_Listener); > // Send the messages > ITextMessage textMessage = session.CreateTextMessage("1st"); > textMessage.NMSTimeToLive = TimeSpan.FromMilliseconds(800.0); > producer.Send(textMessage); > session.Commit(); > // sends normal message, then immediate retry, then retry after 500 ms, then expire. > Thread.Sleep(2000); > Assert.AreEqual(3, cc.numReceived); > > } > } > class CallbackClass > { > private ISession session; > public int numReceived = 0; > public CallbackClass(ISession session) > { > this.session = session; > } > public void consumer_Listener(IMessage message) > { > numReceived++; > ITextMessage m = message as ITextMessage; > Assert.IsNotNull(m); > Assert.AreEqual("1st", m.Text); > session.Rollback(); > } > } > {code} -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira