Hi Yeah for error handler you only refer to an existing error handler using errorHandlerRef. But <onException> can do all the same as an <errorHandler> does also.
On Sat, Feb 7, 2015 at 12:35 AM, Mark Kusec <mku...@mdacorporation.com> wrote: > Thanks Claus, I was able to get onException working by putting it inside the > route in my route definition file. > > <routes xmlns="http://camel.apache.org/schema/spring"> > <route id="foo"> > <onException> > ... > > I could not figure a way to define an error handler or > redeliveryPolicyProfile in a route definition file (as with bean definitions, > it doesn't seem that Camel wants to read these kinds of definitions from a > route definition file). > > In order to specify an error handler, I had to add it to the SimpleRegistry > manually before loading the routes, i.e.: > > DeadLetterChannelBuilder errorHandler = new > DeadLetterChannelBuilder(); > > errorHandler.getRedeliveryPolicy().setMaximumRedeliveries(3); > > errorHandler.getRedeliveryPolicy().setRedeliveryDelay(5000); > errorHandler.setDeadLetterUri(deadLetterDestination); > registry.put("deadLetterHandler", errorHandler ); > > Then I could refer to it in the route definition file: > > <routes xmlns="http://camel.apache.org/schema/spring"> > <route id="foo" errorHandlerRef="deadLetterHandler"> > ... > > But in the end, I found that I could get my desired retry behavior using > onException alone, so I abandoned the approach of registering an error > handler programmatically. > > Is there a better way to use an error handler in conjunction with a route > definition file, other than the SimpleRegistry approach that I showed above? > > Thanks > Mark > > > -----Original Message----- > From: Claus Ibsen [mailto:claus.ib...@gmail.com] > Sent: Friday, February 06, 2015 12:14 AM > To: users@camel.apache.org > Subject: Re: Retry strategy with loadRoutesDefinition > > Hi > > You can inline error handler and onException in your XML routes. > > On Thu, Feb 5, 2015 at 8:16 PM, Mark Kusec <mku...@mdacorporation.com> wrote: >> Hi all, >> >> I have refactored a legacy Java application (i.e. no web container) to use >> Camel to send messages from files to a queue. I chose to describe my routes >> in XML so the routes could be re-used in a future Spring web application. >> My legacy application loads the XML routes using >> ModelCamelContext.loadRoutesDefinition(). >> >> Because I don't have Spring, I'm limited in what I can describe in my XML >> file. Although the documentation isn't too specific, I believe that the XML >> file can only contain routes. For example, I can't declare beans in the XML >> file, so I declare them in a SimpleRegistry and provide that to the >> CamelContext before I load the routes definition file. >> >> I am having trouble finding a way to give Camel a retry strategy for when >> there are connectivity issues with the broker. How would I give Camel >> instructions on how many times to retry, backoff multipliers, etc? >> >> Since my XML file only contains routes, it doesn't seem like I can use >> <onException> or <errorHandler>. Is there some alternate way to declare >> either of these, without switching to the Java DSL? >> >> (Also, according to >> http://camel.465427.n5.nabble.com/global-onException-doesnt-apply-for-routes-loaded-with-loadRoutesDefinition-td4288369.html#a4290365, >> it appears that routes loaded via loadRoutesDefinition don't get the >> benefit of onException anyway, at least not until Camel 3.) >> >> If I'm on the wrong track, is there some other way that I can tell Camel to >> retry periodically (forever) when it is unable to send to a queue? >> >> Thanks, >> Mark >> > > > > -- > 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/