EraCat
EraCat

Reputation: 65

Apache Camel. Base configuration for all routes

I have a lot of routes for which need to add general error handling and do some actions, such as logging, adding information (headers), etc. I do this in runtime now that gather all the routes from the camel context and delete them and instead new RouteBuilders are added with all the necessary actions. But it takes for a very long time to start, because you need to stop, delete, add and start new routes. Is there any way to solve this problem in more efficient way?

One of the options for me is transforming xml files, but may be there is an option through Java dsl. maybe camel 3.0 can solve this?

Upvotes: 1

Views: 733

Answers (1)

Greenev
Greenev

Reputation: 909

Have you already looked at Camel's intersept feature?
Using it you could for example add a custom header to every Exchange in your routes

<interceptFrom uri="*">
    <setHeader headerName="specific"><simple>42</simple></setHeader>
</interceptFrom>

Answering to the rest of your question, to configure general error handling and logging you have an option of using onException and onCompletion blocks, which would be applied for every route in the CamelContext they were provided

Upvotes: 1

Related Questions