Hi,
I have a Camel routeTemplate like this:
public class MyRouteTemplates extends RouteBuilder {
@Override
public void configure() throws Exception {
// create a route template with the given name
routeTemplate("myTemplate")
// here we define the required input parameters (can have
default values)
.templateParameter("name")
.templateParameter("greeting")
.templateParameter("myPeriod", "3s")
// here comes the route in the template
// notice how we use {{name}} to refer to the template parameters
// we can also use {{propertyName}} to refer to property
placeholders
.from("timer:{{name}}?period={{myPeriod}}")
.setBody(simple("{{greeting}} ${body}"))
.log("${body}");
}
}
And I like to call it from a route as a Kamelet like this:
from("direct:a")
.to("kamelet:myTemplate?someparameters")
How to make "myTemplate" available to the CamelContext?
I saw in camel-examples that is using camel-main that you can do it like
this:
Main main = new Main();
main.configure().addRoutesBuilder(MyRouteTemplates.class);
However I am not using main, but Camel core. So I tried it like:
MyRouteTemplates myRouteTemplates = new new MyRouteTemplates();
myRouteTemplates.addRoutesToCamelContext(context);
or
context.addRoutes(myRouteTemplates);
However I get "org.apache.camel.component.kamelet.KameletNotFoundException:
Kamelet with id myTemplate not found in locations: classpath:/kamelets".
This was using Camel 3.14.4
What is the correct way to register/load routeTemplate so they can used by
a Kamelet endpoint?
Raymond