Programmatically adding the context context of onCompletion () to the camel context

Is there a way to add the onCompletion context context handler to the Camel context? The Camel onCompletion documentation shows how to do this with Spring XML-DSL, and I could not find a way to do this programmatically.

+4
source share
2 answers
// define a global on completion that is invoked when the exchange is complete onCompletion().to("log:global").to("mock:sync"); 
+1
source

Since onComplete can only be RouteBuilder actions. To create a truly global onComplete processor

 // Initialize an instance of the definition OnCompletionDefinition globalOnComplete = new OnCompletionDefinition(); globalOnComplete.to("log:onComplete"); 

In your RouteBuilder implementation RouteBuilder before defining any routes, add the above example to the definition

 @Override public void configure() throws Exception { // Add onCompletion instance for all routes within this RouteBuilder this.getRouteCollection() .getOnCompletions() .add(globalOnComplete); // Route definition from("direct:input").to("log:output"); } 
0
source

Source: https://habr.com/ru/post/1485871/


All Articles