Claus,
Thanks for the quick reply. I too came across the link you provided during
my previous searches.
Unfortunately, I don't think that solution helps me out very much in my
case. Presumably, to use the above solution, I'd have to dynamically update
the xml file after receiving a "change" event. In my case, I can't have the
route "logic" centrally located and there's no omniscient object that would
know how to (re-)generate the routes in any case.
I ended up with the following solution, in case anyone cares:
- Created a an I/F "X" that "restartable" Routebuilders would implement that
has "Set<String> getRouteIds()" method. That method returns the route ids of
the routes created by this RouteBuilder.
- Created a "RestartBean" (Application and Camel context aware) that's part
of the route listening for the "change event", which does the following:
- Uses the spring application context to find all "restartable"
Routebuilders instances. [They need to scoped as prototype beans in order to
get "new", uninitialized RouteBuilder instances.]
- Then for each "restartable" Routebuilder:
- Use the getRouteIds() methods to find out which routes those
RouteBuilders created
- Stop/Remove those routes
- Pass the "new" Routebuilder instance to camelContext.addRoutes(...)
This has the desirable effect, for me, to keep the route building logic
local to the RouteBuilders and allowing me to re-initialize those
RouteBuilders (and the dynamic routing info they create) at runtime.
Regards
--
View this message in context:
http://camel.465427.n5.nabble.com/Re-initializing-route-builders-at-runtime-under-Spring-tp5660040p5662597.html
Sent from the Camel - Users mailing list archive at Nabble.com.