camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: cannot exchange mesasge body during a retryWhile()
Date Mon, 27 Jan 2014 07:46:51 GMT
Hi

retryWhile is only for returning true|false, not for modifying. You
should use onRedelivery to do any custom modifications before a
redelivery attempt.



On Sun, Jan 26, 2014 at 7:40 PM, Elvio Caruana (ecaruana)
<ecaruana@cisco.com> wrote:
> Hi all,
>
> I've got a scenario where given an exception on a route, I want to retry the sub-route
but with a modified body (String.class type).
>                                 from("direct:foo")
>              .onException(SomeException.class)
>              .handled(true)
>              .retryWhile(new Predicate() {
>                 @Override
>                 public boolean matches(Exchange exchange) {
>                            if (canContinue()) {
>                               exchange.getIn().setBody("newly modified string");
>                               return true;
>                            }
>                            else {
>                                   return false;
>                            }
>
>                                      }
>                               }).end()
>                              .to("direct:bar");
>
> The retries are being done correctly and exhausted at the right time - however every
retry always has the original body, and not the modified string body I was expecting. Am I
not able to modify the exchange body on retry?
>
> Many Thanks,
> Elvio
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io

Mime
View raw message