I am building a route dynamically based on some conditions. For example, based on the configuration, the from route can be a quartz2 or file component. All the other portions of the route are same.
File Component Route
from(file://E:/Camel)
.setProperty("fileName", simple("${file:onlyname}"))
.process(camelprocessor)
.to(queue)
.log("Posted message to Queue");
Quartz2 Component Route
from(quartz2://schedulername?cron=0+0/5+12-18+?+*+MON)
.pollEnrich(file://E:/Camel)
.setProperty("fileName", simple("${file:onlyname}"))
.process(camelprocessor)
.to(queue)
.log("Posted message to Queue");
As you see in the routes above, the last four lines are same for both the route. Currently, we are connecting the from portion (timer or quartz2 component) of the route to the common route with the help of direct component.
Is this a right approach? Will there be any performance issue if we use direct component?
The other options that we have are thinking are :
- Duplicate the common portion of the route in both the routes.
- Use content based routing but not sure how to use the condition on the from component itself.
I appreciate any advice regarding the above.