Reputation: 1071
I write an Application to load Camel Routes.
I have a Spring - Camel instance. Now i would load "Modules" to order my routes, and to have the posibility to de- / active a set of Route by this Module.
So I write a XML File and unmarschal this to Java-Classes. Every module is now a Java-Class. And I want to define the Camel Routes inside this Java-Classes.
When I extends the Java-Classes from RouteBuilder, JAXB don't marschal that than.
Have some one of you an idea how I can define my routes like "from().to()" in a method from a class which is not extends from RouteBuilder?
Thank you for all ideas!!!
Upvotes: 0
Views: 1535
Reputation: 1071
Oh, I write my Question, 5 minutes ago I found the solution:
public class XYZ {
public static RouteBuilder routen() {
RouteBuilder builder = new RouteBuilder() {
public void configure() {
errorHandler(deadLetterChannel("mock:error"));
from("file:documentIn").id("DefaultRoute")
.to("file:documentOut");
}
};
return builder;
}
}
Thank you all, and sorry!
Upvotes: 2
Reputation: 2676
You could annotate yout RouteBuilder classes and use dependency injection in order to include them or not in the camel startup.
Another possibility is using maven modules ... then depending if a specific module is present or not the routes it contains will be loaded or not.
Those both two solutions has worked for me in combination in the past ... but trying to use camel routes that does not extends from RouteBuilder i haven't tried ... not sure if it's a good approach.
Good luck.
Upvotes: 0