You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Matthew Good (JIRA)" <ji...@apache.org> on 2011/03/31 01:29:05 UTC

[jira] [Created] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

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


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();
            }
        }



--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Timothy Bish resolved AMQNET-323.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 1.6.0
                   1.5.1
         Assignee: Timothy Bish  (was: Jim Gomes)

Fixed in trunk and 1.5.x fixes.  Thanks for the great unit tests.

> 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: Timothy Bish
>             Fix For: 1.5.1, 1.6.0
>
>         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

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Jim Gomes (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13014732#comment-13014732 ] 

Jim Gomes commented on AMQNET-323:
----------------------------------

Tim, regarding the setting of the NMSTimeToLive, that can be set at any time.  It doesn't start the countdown, so to speak, until the message is actually sent.  This is why we don't set an expiration time, which is what the JMS spec uses.  We set a time to live, and when the message is actually sent, then it is converted into an expiration time per JMS standards.  So there's no rush to try and send a message before it expires.

> 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: Timothy Bish
>             Fix For: 1.5.1, 1.6.0
>
>         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

[jira] [Issue Comment Edited] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Matthew Good (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13013730#comment-13013730 ] 

Matthew Good edited comment on AMQNET-323 at 3/30/11 11:35 PM:
---------------------------------------------------------------

The ActiveMQ server and client were running on the same machine.
The ActiveMQ server did recognize the expiration so when the client finally closed, this appeared in the ActiveMQ server log.

 WARN | ignoring ack MessageAck {commandId = 25, responseRequired = false, ackType = 2, consumerId = ID:MY_BOX-55460-634371021231957237-1:0:1:1, firstMessageId = ID:MY_BOX-55460-634371021231957237-1:0:1:1:1, lastMessageId
= ID:MY_BOX-55460-634371021231957237-1:0:1:1:1, destination = temp-queue://ID:MY_BOX-55460-634371021231957237-1:0:1, transactionId = TX:ID:MY_BOX-55460-634371021231957237-1:0:6, messageCount = 1}, for already expired message: Message ID:MY_BOX-55460-634371021231957237-1:0:1:1:1 dropped=false acked=false locked=true


      was (Author: matt_good@yahoo.com):
    The ActiveMQ server and client were running on the same machine.
The ActiveMQ server did recognize the expiration so when the client finally closed, this appeared in the ActiveMQ server log.

 WARN | ignoring ack MessageAck {commandId = 25, responseRequired = false, ackType = 2, consumerId = ID:MY_BOX-55460-634371021231957237-1:0:1:1, firstMessageId = ID:MY_BOX-55460-634371021231957237-1:0:1:1:1, lastMessageId
= ID:MY_BOX-55460-634371021231957237-1:0:1:1:1, destination = temp-queue://ID:MY_BOX-55460-634371021231957237-1:0:1, transactionId = TX:ID:MY_BOX-55460-634371021231957237-1:0:6, messageCount = 1}, for already expired message: Message ID:IPC-DEN-NTB-237-55460-634371021231957237-1:0:1:1:1 dropped=false acked=false locked=true

  
> 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
>
> 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();
>             }
>         }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13014194#comment-13014194 ] 

Timothy Bish commented on AMQNET-323:
-------------------------------------

We need to leave the NMSTimeToLive setter as its used by the Message transformation stuff to pass through the Message properties when converting one providers Message type to another's.  

I think the thing to do is just clearly define what the MessageProducer does in its various send methods.  Right now it seems there's at least three ways that a TTL value can get set or accidentally be set, maybe four.  I just find the current methodology kinda confusing and it just feels error prone to me.  I don't mind if we deviate from the JMS spec in some areas, but when we do we should really be careful to make it clear in the NMS API docs.

Having the producer actually compute the expiration time and set it seems best since a Message could also be created ahead of time and not sent right away, and since NMSTimeToLive takes a TimeSpan it could result in messages getting timed out our way to early.  

@Matthew, I'm looking into the test failure now, think I know where its going wrong, will report back when I have a fix.

> 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

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Jim Gomes (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13014138#comment-13014138 ] 

Jim Gomes commented on AMQNET-323:
----------------------------------

I just checked my JMS reference book ("Enterprise JMS Programming") to see how it deals with this.  It clearly shows an example of creating a message, setting the TTL on that message, and then sending it via a simple send message command.  The direct implication being that the TTL that is set on the message would be respected and not overriden by the producer.

Shortly after that example, it showed an example of how a semi-global default TTL is set on a per-session basis.  NMS doesn't have this concept, but it does have a per-producer setting, which is what you were expecting to be set.  It's currently possible to get the behavior you were expecting, but it takes some manual overrides instead of relying on defaults.  Something like the following would do what you would want to have by default:

{code}
producer.Send(msg, producer.DeliveryMode, producer.Priority, producer.TimeToLive);
{code}

With NMS, we have a good way of setting these defaults because we have the ability to create messages via the producer instead of only via the session.  I suggest that the {{Producer.CreateMessage()}} set of functions be modified to set the newly created message's {{NMSTimeToLive}} property to the producer's {{TimeToLive}}.  This would be a reasonable way to allow maximum flexibility.  The user can set the default time to live for a given producer, but still have the option of overriding it on a message-by-message basis without having to call a different send API to do so.


> 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

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13014106#comment-13014106 ] 

Timothy Bish commented on AMQNET-323:
-------------------------------------

I just looked at the Producer code, I didn't realize that it had been implemented that way.  O personally think that incorrect, the point of the producer methods that don't specify a TTL is that it should respect the set value in the Producer and not take something from the Message.  It kind of negates the point of having a TTL setting in the Producer and is inconsistent with the other Message properties like priority and delivery mode which are always defaulted to the values set in the Producer.  If the user wants to override the set TTL it should be done by calling the appropriate producer send method.

> 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

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13014742#comment-13014742 ] 

Timothy Bish commented on AMQNET-323:
-------------------------------------

Ok, take your word for it as I don't have time to really look at it right now, all I can say is that from a cursory glance yesterday I couldn't really determine when and whose TTL value gets set where.  So when someone ask me about NMS TTL all I can say is, "your guess is as good as mine."

> 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: Timothy Bish
>             Fix For: 1.5.1, 1.6.0
>
>         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

[jira] [Resolved] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Timothy Bish resolved AMQNET-323.
---------------------------------

    Resolution: Not A Problem

User not calling Producer send with TTL param.

> 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
>
> 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();
>             }
>         }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13014156#comment-13014156 ] 

Timothy Bish commented on AMQNET-323:
-------------------------------------

Ok, more from the spec then:

{noformat}
public void send(Destination destination,
                 Message message)
          throws JMSException

    Sends a message to a destination for an unidentified message producer. Uses the MessageProducer's default delivery mode, priority, and time to live.

    Typically, a message producer is assigned a destination at creation time; however, the JMS API also supports unidentified message producers, which require that the destination be supplied every time a message is sent.

{noformat}

Notice the verbage, *Uses the MessageProducer's default delivery mode, priority, and time to live.*



> 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

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13014039#comment-13014039 ] 

Timothy Bish commented on AMQNET-323:
-------------------------------------

Producer send always set TTL, so no matter what you set in the Message before calling send the value will not stick.  Sounds like we aren't properly clearing all the Message fields in the send which though, probably worth a look as well.

> 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
>
> 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();
>             }
>         }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13013966#comment-13013966 ] 

Timothy Bish commented on AMQNET-323:
-------------------------------------

To send a Message with a TTL you need to use the MessageProducer's send method with TTL param, setting it directly on the Message has no affect on TTL of a sent Message.

> 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
>
> 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();
>             }
>         }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13014141#comment-13014141 ] 

Timothy Bish commented on AMQNET-323:
-------------------------------------

Per JMS Spec: 

{noformat}
setJMSExpiration()

Sets the message's expiration value.

JMS providers set this field when a message is sent. This method can be used to change the value for a message that has been received.
{noformat}

Which means the example in that book is wrong or the provider they used didn't honer this portion of the spec.

With current implementation if I receive a Message that has a TTL set and I resend it to another Queue it would retain the old TTL and not honor the settings of my producer so if I wanted to dispatch it to multiple producers some with and some without TTL I have to be manage this with every message send instead of just specifying a TTL when I create the producer and relying on that.

> 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

[jira] [Reopened] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Matthew Good (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matthew Good reopened AMQNET-323:
---------------------------------

    Regression: [Unit Test Broken]

I changed the unit test to use a send method that takes a ttl parameter.  Stepping into the code, I see that all it does is set the NMSTimeToLive like I was doing before.  So first, there is no difference whether I set NMSTimeToLive myself or use the Send method that takes a TTL parameter.

The unit test still fails.

> 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
>
> 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();
>             }
>         }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13014036#comment-13014036 ] 

Timothy Bish commented on AMQNET-323:
-------------------------------------

Please attach updated unit tests with correct call to producer send with TTL as a patch file or complete source, pasted code in JIRA loses all line breaks and other formatting.

> 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
>
> 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();
>             }
>         }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Jim Gomes (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13014185#comment-13014185 ] 

Jim Gomes commented on AMQNET-323:
----------------------------------

Agreed.  I found the following from the JMS 1.0.2 Spec:

{noformat}
When a message is sent, expiration is left unassigned. After completion of the send method, it holds the expiration time of the message. This is the sum of the time-to-live value specified by the client and the GMT at the time of the send.
{noformat}

Combining that with your reference clearly shows that setting the TTL of a message happens in a just-in-time fashion during the Send() operation.  This makes me question the value of having the NMSTimeToLive property as a read/write property instead of just a read-only property.  It gives a false impression that setting it will have any impact whatsoever.

Matthew, apologies for the digression, but I didn't forget the main issue.  I didn't intend to hijack the original bug.  Guess it's time to enter a separate issue for the TTL setting.  Tim, would you like to enter it?

> 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

[jira] [Updated] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Jim Gomes (JIRA)" <ji...@apache.org>.
     [ 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

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Matthew Good (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13013730#comment-13013730 ] 

Matthew Good commented on AMQNET-323:
-------------------------------------

The ActiveMQ server and client were running on the same machine.
The ActiveMQ server did recognize the expiration so when the client finally closed, this appeared in the ActiveMQ server log.

 WARN | ignoring ack MessageAck {commandId = 25, responseRequired = false, ackType = 2, consumerId = ID:MY_BOX-55460-634371021231957237-1:0:1:1, firstMessageId = ID:MY_BOX-55460-634371021231957237-1:0:1:1:1, lastMessageId
= ID:MY_BOX-55460-634371021231957237-1:0:1:1:1, destination = temp-queue://ID:MY_BOX-55460-634371021231957237-1:0:1, transactionId = TX:ID:MY_BOX-55460-634371021231957237-1:0:6, messageCount = 1}, for already expired message: Message ID:IPC-DEN-NTB-237-55460-634371021231957237-1:0:1:1:1 dropped=false acked=false locked=true


> 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
>
> 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();
>             }
>         }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Jim Gomes (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13014148#comment-13014148 ] 

Jim Gomes commented on AMQNET-323:
----------------------------------

The portion of the Spec that you quoted doesn't mention anything about *when* the expiration value is set, or which component in the provider sets it.  I think we have different expectations of the precedence of setting TTL on a given message.  And it really only comes down to what will happen with the default {{producer.Send(msg)}} function. The expectation with the other overrides is very clear, because the TTL is specified explicitly in the function call.

Like I mentioned, I prefer keeping the current implementation of Send() the way it is, and adding code to the {{Producer.CreateMessage()}} functions to pre-configure the TTL for the message.  In order to achieve support for the message relay scenario you mention, what do you think of adding a boolean property to the Producer that will set the producer's default TTL on messages that are sent via the {{producer.Send(msg)}} function?  I think if the TTL is specified explicitly in the send function, then it needs to be used instead of the producer's TTL.

> 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

[jira] [Updated] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Matthew Good (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matthew Good updated AMQNET-323:
--------------------------------

    Attachment: TtlUnitTest.txt

Unit tests.  First one is good and shows Receive works correctly.  Second fails and shows callbacks don't work correctly.

You can paste these in AMQRedeliveryPolicyTest.

> 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
>         [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();
>             }
>         }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Matthew Good (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13014155#comment-13014155 ] 

Matthew Good commented on AMQNET-323:
-------------------------------------

Although there might be some issue with how TTL is set, Please don't lose track of the original problem this bug is about.  The unit test is setting a TTL (one way or another) and the code that deals with listener call backs and retries is not respecting it.  I know TTL is getting set because the ActiveMQ server does move it to DLQ at the appropriate time when it expires.

> 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

[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback

Posted by "Jim Gomes (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13014067#comment-13014067 ] 

Jim Gomes commented on AMQNET-323:
----------------------------------

The Producer doesn't always set the TTL.  There is some complex logic in there around setting the TTL, but it's a necessary level of complexity.  There are four overloaded public Send() functions.  The first two overloaded versions will respect the message's TTL setting.  The second two overloaded versions will set the TTL on the message to what is passed in as a parameter.

I think the Send() function code is correct, and it is not necessary to call the second set of Send() functions in order to have a TTL set on a message.

I haven't studied the original redelivery issue report unit tests yet.

> 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
>         [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();
>             }
>         }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira