How to run an Apache Camel integration with Camel K containing: XML file & .java file

11/21/2019

Document of Apache Camel K guides how to run an integration wroten by XML. But when I need to write custom code in Java (processors, transform), I can not find the way to run them together. So, have Camel K supported this features? If it have, how can I do that?

-- Nickie
apache-camel
kubernetes

1 Answer

11/21/2019

You can mix languages like

kamel run --name my-app routes.xml routes.java

Then if your need is to write custom processors in java, then you can bind such processors to the camel registry from your configure method like

getContext().getRegistry().bind("myProcessor", new Processor() { ... }

or by annotating methods with @BindToRegistry in tour RouteBuilder class like

@BindToRegistry("my-processor")
Processor myProcessor() {
    return exchange -> { ... }
}
-- Luca Burgazzoli
Source: StackOverflow