camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Kusec <>
Subject RE: Retry strategy with loadRoutesDefinition
Date Fri, 06 Feb 2015 23:35:11 GMT
Thanks Claus, I was able to get onException working by putting it inside the route in my route
definition file.

<routes xmlns="">
  <route id="foo">

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();
		    registry.put("deadLetterHandler", errorHandler );

Then I could refer to it in the route definition file:

<routes xmlns="">
  <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?

-----Original Message-----
From: Claus Ibsen [] 
Sent: Friday, February 06, 2015 12:14 AM
Subject: Re: Retry strategy with loadRoutesDefinition


You can inline error handler and onException in your XML routes.

On Thu, Feb 5, 2015 at 8:16 PM, Mark Kusec <> 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,
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.
Twitter: davsclaus
Author of Camel in Action:

View raw message