In my project I have several routes, which all have a similar setup. Concrete values for endpoints and property-values as well as which processors should be used are resolved from a config-file.
Thus, I created a method to setup those routes. One parameter is a List or Array of processor-names. Is there a possibility to add a this list of processor-references to the route-definition?
protected void setupRoute(String routeKey, String nbiSystemName, String requestEndpointUrl,
String defaultSbi, String reqSwitchRouteId, ArrayList<String> processorNames) {
from(requestEndpointUrl)
.routeId(routeKey).transacted()
.setProperty(PROPERTY_CBS_STARTTIME, simple("${date:now:yyyy-MM-dd'T'HH:mm:ss.SSS'Z'}"))
.setProperty(PROPERTY_CBS_NBI, constant(nbiSystemName))
.setProperty(PROPERTY_CBS_SBI, constant(defaultSbi))
// At this place I want to add all of the processors like
// .process("processorName")
.to("direct:" + reqSwitchRouteId );
}
As a workaround I considered using .loop() or .loopDoWhile() with beans instead of processors.
But this is the wrong approach from my point of view, because I already know which processors should be used when I setup the route-definition.