[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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);
[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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
[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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;
[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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;
[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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 =
[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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
[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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 =
[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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
[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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);
[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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
[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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
[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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.
[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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);
[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13013733#comment-13013733 ] Matthew Good commented on AMQNET-323: - Not sure if this is related to this issue with NMS client or a different issue with Administration Console... If the timeToLive has NOT expired and the client is in the redelivery loop as in the TestNornalRedeliveryPolicyOnRollbackUntilTimeToLiveCallback method above, you can delete or purge the message in the administration console and the client continues to retry. I would expect either the console would not allow delete/purge or the client should stop retrying the 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
[jira] [Commented] (AMQNET-323) NMS Client does not respect TimeToLive with Listener callback
[ https://issues.apache.org/jira/browse/AMQNET-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13013738#comment-13013738 ] Timothy Bish commented on AMQNET-323: - Redelivery is a local operation for the client, so deleting the message at the Console will have no effect on the client regardless of whether its correctly dealing with the TTL value or not. 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