[
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