On Fri, Nov 16, 2012 at 4:09 PM, Erkki Lindpere <[email protected]> wrote: > Thanks, Christian and Claus, this helped -- I didn't realize before that I > should do the stopping in a separate thread. This works with some examples > I'm trying. > > Do you know if this approach should work when I have to stop multiple > routes? Because I think I need to stop every route created by one > RouteBuilder before I let it recreate them. > > For example, if I start the thread to stop all 3 routes in the > camel-example-cxf-tomcat while a message in the 1st route is being > processed, the processing will fail -- with various exceptions depending on > timing, one case being that there is no consumer for the "direct:..." > endpoint where the message is sent from route 1 (and where route 2 or route > 3 should consume it). > > I'm not sure what a good solution is in such a case, or in the general case > where the routes may be even more complex. >
Ah yeah. CamelContext keeps track on the best starting order, and thus also the best shutdown order. It does this a bit behind the scene. Though the ShutdownStrategy API accepts a List<RouteStartupOrdeR> instances that dictates this ordering. So in your use-case, its a matter of tapping into that, and using that when shutting down the RouteBuilder. Then you would shutdown in the same order as Camel will do it by itself when you shutdown Camel. We may open the API a bit to make it easier for SPI tooling to tap into this in a simpler way. > Erkki > > On Fri, Nov 16, 2012 at 9:43 AM, Claus Ibsen <[email protected]> wrote: > >> On Thu, Nov 15, 2012 at 2:11 PM, Erkki Lindpere >> <[email protected]> wrote: >> > Hi, >> > >> > I'm from ZeroTurnaround and started working on a JRebel Camel plug-in. >> The >> > current plan is to update routes whenever a RouteBuilder class changes. >> > Feel free to suggest other things that a JRebel-Camel plug-in should do. >> > >> >> Ah this sounds very cool. >> >> > I have a basic prototype working, and what I do is >> removeRouteDefinitions, >> > then rerun the RouteBuilder to add the changed ones back. >> > >> > A problem I have is when to trigger a reload. If I trigger it once a >> > message comes in (JRebel usually does things lazily), the reloading of >> the >> > route causes the message in progress to fail. >> > >> >> If you remove the route first using that API call ^^^, then Camel will >> stop the routes first in a graceful manner. >> http://camel.apache.org/graceful-shutdown.html >> >> > Is there any way to safely find a point where a route can be updated? >> > >> >> So after this call, then there ought not to be any inflight messages. >> And a safe point to reload a new RouteBuilder with routes. >> >> >> > Regards >> > Erkki Lindpere >> >> >> >> -- >> Claus Ibsen >> ----------------- >> Red Hat, Inc. >> FuseSource is now part of Red Hat >> Email: [email protected] >> Web: http://fusesource.com >> Twitter: davsclaus >> Blog: http://davsclaus.com >> Author of Camel in Action: http://www.manning.com/ibsen >> -- Claus Ibsen ----------------- Red Hat, Inc. FuseSource is now part of Red Hat Email: [email protected] Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen
