Hi

Thanks for your answers and help. I ended up using your advice to use the 
redeliveryPolicy to set the maximumRedeliveries to 0 on my activemq connection. 
That helped. Thanks again!
 
On Jun 15, 2011, at 2:57 PM, Claus Ibsen wrote:

> I have improved the logic in the trunk code
> https://issues.apache.org/jira/browse/CAMEL-4106
> 
> On Wed, Jun 15, 2011 at 11:43 AM, Claus Ibsen <claus.ib...@gmail.com> wrote:
>> On Tue, Jun 14, 2011 at 9:18 PM, Morten Holm <m...@tradeshift.com> wrote:
>>> On Tue, Jun 14, 2011 at 6:13 PM, Claus Ibsen <claus.ib...@gmail.com> wrote:
>>> 
>>>> On Tue, Jun 14, 2011 at 5:08 PM, Morten Holm <m...@tradeshift.com> wrote:
>>>>> Hi
>>>>> 
>>>>> Redelivery is not disabled when maximumRedeliveries is set to 0. I
>>>> experience that one redelivery is always attempted.
>>>>> 
>>>>> The errorhandler  looks like this.
>>>>> 
>>>>>        <errorHandler xmlns="http://camel.apache.org/schema/spring";
>>>> id="failedMessagesErrorHandler"
>>>>>                type="DeadLetterChannel" deadLetterUri="jms:deadLetters"
>>>> useOriginalMessage="true">
>>>>>                <redeliveryPolicy maximumRedeliveries="0"/>
>>>>>        </errorHandler>
>>>>> 
>>>>> 
>>>> 
>>>> You can enable logging for redelivery (retry) and set a high logging
>>>> level like WARN etc. so you can notice it in the logs.
>>>> 
>>>> <xs:attribute name="retryAttemptedLogLevel" type="tns:loggingLevel"/>
>>>> <xs:attribute name="logRetryAttempted" type="xs:string"/>
>>>> 
>>>> But using 0 ought not to attempt redeliveries, unless you have
>>>> <onException> or something else that has a policy which overrides the
>>>> <errorHandler>.
>>>> 
>>>> 
>>>>> It seems like the last line could be the problem:
>>>>> 
>>>>> From RedeliveryPolicy.java:
>>>>>   /**
>>>>>    * Returns true if the policy decides that the message exchange should
>>>> be
>>>>>    * redelivered.
>>>>>    *
>>>>>    * @param exchange  the current exchange
>>>>>    * @param redeliveryCounter  the current retry counter
>>>>>    * @param retryWhile  an optional predicate to determine if we should
>>>> redeliver or not
>>>>>    * @return true to redeliver, false to stop
>>>>>    */
>>>>>   public boolean shouldRedeliver(Exchange exchange, int
>>>> redeliveryCounter, Predicate retryWhile) {
>>>>>       // predicate is always used if provided
>>>>>       if (retryWhile != null) {
>>>>>           return retryWhile.matches(exchange);
>>>>>       }
>>>>> 
>>>>>       if (getMaximumRedeliveries() < 0) {
>>>>>           // retry forever if negative value
>>>>>           return true;
>>>>>       }
>>>>>       // redeliver until we hit the max
>>>>>       return redeliveryCounter <= getMaximumRedeliveries();
>>>>>   }
>>>> 
>>> Thanks for the fast reply. I have no <onException> so that cannot be the
>>> reason.
>>> I have run through the code with a debugger and the message is tried resend
>>> once. It seems like the following line always will return true
>>> 
>>>  return redeliveryCounter <= getMaximumRedeliveries();
>>> 
>>> So couldn't that be the problem ? in my case both variables would be 0 and
>>> the method would return true.
>>> 
>> 
>> The error handler logic is *always* executed during routing. So in non
>> error situations the shouldRedeliver is invoked as well. And that is
>> why you see 0 as the redelivery counter.
>> 
>> You could possible argue that the name of the method (shouldRedeliver)
>> ought only to be invoked if we are doing a redelivery. So we should
>> consider improving this logic. I will log a ticket for that.
>> 
>> 
>> 
>> 
>> 
>> 
>>> 
>>> 
>>>> 
>>>>> Am I doing something wrong ? Are there some properties that I have to set
>>>> ?
>>>>> 
>>>>> -- camel version: 2.7.1
>>>>> 
>>>>> --
>>>>> Morten Holm
>>>>> Developer
>>>>> 
>>>>> Voice: +45 31 18 91 08
>>>>> Skype: morten.holm
>>>>> 
>>>>> http://tradeshift.com - INVOICING HAS NEVER BEEN EASIER
>>>>> 
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> --
>>>> Claus Ibsen
>>>> -----------------
>>>> FuseSource
>>>> Email: cib...@fusesource.com
>>>> Web: http://fusesource.com
>>>> Twitter: davsclaus, fusenews
>>>> Blog: http://davsclaus.blogspot.com/
>>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>>> 
>>> 
>>> 
>>> 
>>> --
>>> Morten Holm
>>> Developer
>>> 
>>> Voice: +45 31 18 91 08
>>> Skype: morten.holm
>>> 
>>> http://tradeshift.com - INVOICING HAS NEVER BEEN EASIER
>>> 
>> 
>> 
>> 
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cib...@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> 
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> FuseSource
> Email: cib...@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/

-- 
Morten Holm
Developer

Voice: +45 31 18 91 08
Skype: morten.holm

http://tradeshift.com - INVOICING HAS NEVER BEEN EASIER

Reply via email to