Hi There was maybe a but about changing the max redelivery counter - you can try with latest release / SNAPSHOT.
And there is also retryWhile which returns a boolean then you can control the logic there also. On Wed, Feb 11, 2015 at 6:51 PM, Rafiq, Adnan <ara...@onenetwork.com> wrote: > Thanks, Claus. > > I'm assuming that I must be doing something wrong here. > I am trying to set the max redelivery to 3 in the example below, but it looks > like it does not have any effect. Camel only tries to redeliver it once > instead of overriding the REDELIVERY_MAX_COUNTER to 3. > > > Here's the code: > > from("direct:HLTH.HttpOutbound") > .errorHandler(defaultErrorHandler() > .maximumRedeliveries(1) > .redeliveryDelay(1000) > .onRedelivery(new Processor() { > > @Override > public void process(Exchange exch) throws Exception { > > LOG.info("Redelivery Max Counter: " + > exch.getProperty(Exchange.REDELIVERY_MAX_COUNTER)); > LOG.info("Redelivery Delay: " + > exch.getProperty(Exchange.REDELIVERY_DELAY)); > > // verified that maxRedeliveries was set to 3 > Integer maxRedeliveries = (Integer) > exch.getIn().getHeader("MaxRedeliveries"); // this was set to 3 by the > producer template > if (maxRedeliveries != null) > exch.setProperty(Exchange.REDELIVERY_MAX_COUNTER, maxRedeliveries); > > Long redeliveryDelay = (Long) > exch.getIn().getHeader("RedeliveryDelay"); > if (redeliveryDelay != null) > exch.setProperty(Exchange.REDELIVERY_DELAY, redeliveryDelay); > } > })) > .setHeader(Exchange.HTTP_URI, header("HTTP_URI")) > .setHeader("CamelHttpMethod", constant("POST")) > .to("http4://127.0.0.1"); > > } > > I am quite sure I am approaching this wrong due to my lack of expertise with > camel. > > Thanks > > -----Original Message----- > From: Claus Ibsen [mailto:claus.ib...@gmail.com] > Sent: Wednesday, February 11, 2015 4:42 AM > To: users@camel.apache.org > Subject: SPAM: Re: How to not hardcode MaxRedeliveries in a route > > Hi > > Use onRedelivery to implement logic whether to redeliver or not. Then that > logic can use headers and whatnot > > On Wed, Feb 11, 2015 at 12:43 AM, arafiq <ara...@onenetwork.com> wrote: >> Camel newbie here and still trying to learn the basics. I have a route >> based on the HTT4 component where I have a MaxRedelivery option set like >> this: >> >> from("direct:HLTH.HttpOutbound") >> .errorHandler(defaultErrorHandler() >> .maximumRedeliveries(3) >> .redeliveryDelay(30000) >> .setHeader(Exchange.HTTP_URI, header("HTTP_URI")) >> .setHeader("CamelHttpMethod", constant("POST")) >> .to("http4://127.0.0.1"); >> >> The problem is that we do not want to hardcode the redelivery policies >> in the route. Rather, I want to set them via the ProducerTemplate's >> sendBodyAndHeader method. I have tried to set it up as an exchange >> header but Camel does not like it: >> >> from("direct:HLTH.HttpOutbound") >> .errorHandler(defaultErrorHandler() >> >> .maximumRedeliveries(Integer.parseInt(header("MaxRedeliveries").toString())) >> .redeliveryDelay(30000) >> .setHeader(Exchange.HTTP_URI, header("HTTP_URI")) >> .setHeader("CamelHttpMethod", constant("POST")) >> .to("http4://127.0.0.1"); >> >> I get a number format exception when starting up the route. >> >> Any ideas on how to NOT hardcode the redelivery policies in the route >> itself? >> >> >> >> >> -- >> View this message in context: >> http://camel.465427.n5.nabble.com/How-to-not-hardcode-MaxRedeliveries- >> in-a-route-tp5762577.html Sent from the Camel - Users mailing list >> archive at Nabble.com. > > > > -- > Claus Ibsen > ----------------- > Red Hat, Inc. > Email: cib...@redhat.com > Twitter: davsclaus > Blog: http://davsclaus.com > Author of Camel in Action: http://www.manning.com/ibsen > hawtio: http://hawt.io/ > fabric8: http://fabric8.io/ -- Claus Ibsen ----------------- Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/