[
https://issues.apache.org/jira/browse/AMQNET-769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17534701#comment-17534701
]
Marco Galassi commented on AMQNET-769:
--------------------------------------
Ok, so is there a way to perform redeliveries with options, if not from the
client?
> Redelivery Options do not work
> ------------------------------
>
> Key: AMQNET-769
> URL: https://issues.apache.org/jira/browse/AMQNET-769
> Project: ActiveMQ .Net
> Issue Type: Bug
> Components: NMS
> Affects Versions: AMQP-2.0.0
> Reporter: Marco Galassi
> Priority: Major
>
> I'm trying to set redelivery options, but they don't seem to work.
> I want to be able to use the redelivery options so that if there is an
> error/issue/something, the message gets sent back to the broker and
> redelivered according to certain options.
> For instance, I want to set:
> * InitialRedeliveryDelay = 500ms
> * BackOffMultiplier = 2
> * UseExponentialBackOff = true
> * MaximumRedeliveries = 5
> I haven't found many examples, but I came up with this by stitching together
> the ActiveMQ documentation, the Apache.NMS.amqp docs and a few online
> examples.
>
>
> {code:java}
> String brokerUri = "amqp://127.0.0.1:5672";
> IConnectionFactory factory = new ConnectionFactory(brokerUri);
> IConnection connection = factory.CreateConnection();
> RedeliveryPolicy rdp = new RedeliveryPolicy();
> rdp.MaximumRedeliveries = 5;
> rdp.BackOffMultiplier = 2;
> rdp.InitialRedeliveryDelay = 5000;
> rdp.UseExponentialBackOff = true;
> connection.RedeliveryPolicy = rdp;
> connection.Start();
> ISession session =
> connection.CreateSession(AcknowledgementMode.ClientAcknowledge);
> IDestination dest = session.GetQueue("foo.bar");{code}
> Then, to read messages, I do:
>
> {code:java}
> IMessageConsumer consumer = session.CreateConsumer(dest);
> DateTime start = DateTime.Now;
> long count = 0;
> Console.WriteLine("Waiting for messages...");
> while (true)
> {
> IMessage msg = consumer.Receive();
> count++;
> ITextMessage txtMsg = msg as ITextMessage;
> String body = txtMsg.Text;
> Console.WriteLine(DateTime.Now + "_" + count + " ____ " + body);
> if (body == "end")
> {
> session.Recover();
> }
> else
> {
> msg.Acknowledge();
> }
> }{code}
> This is not working. The only thing that seems to work is that it correctly
> sets the maximum redeliveries attemps before sending the Poison ACK to the
> Broker.
>
> None of the other options are taken into consideration
>
> I have also tried to pass all these options in the uri, as specified in the
> ([ActiveMQ docs under "Nested
> Options"|[https://activemq.apache.org/connection-configuration-uri])] as
> follows:
>
> {code:java}
> String brokerUri =
> "amqp://127.0.0.1:5672?jms.redeliveryPolicy.maximumRedeliveries=5&jms.redeliveryPolicy.BackOffMultiplier=2&jms.redeliveryPolicy.InitialRedeliveryDelay=2000&jms.redeliveryPolicy.UseExponentialBackOff=true";
> IConnectionFactory factory = new ConnectionFactory(brokerUri);
> IConnection connection = factory.CreateConnection();
> connection.Start();
> ISession session =
> connection.CreateSession(AcknowledgementMode.ClientAcknowledge);
> IDestination dest = session.GetQueue("foo.bar");{code}
> In this case it's even worse because the broker will attempt redelivery
> indefinetly.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)