Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the early version of the new website
https://camel.apache.org/staging/
We would very much like to receive any feedback on the new site, please join the discussion on the Camel user mailing list.
Configuring routes startup ordering and autostartupAvailable as of Camel 2.1 Camel now supports configuring two aspects:
Configuring whether Camel should be auto started or not in XML DSLThe old option For example the route below we have configured autoStartup=false to prevent Camel starting when Spring starts. <camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring" autoStartup="false"> <route> <from uri="direct:start"/> <to uri="mock:result"/> </route> </camelContext> So how do you start Camel then? The autoStartup option on the <camelContext> is only used once, so you can manually start Camel later by invoking its ApplicationContext ac = ... SpringCamelContext camel = (SpringCamelContext) ac.getBean("myCamel"); // now start Camel manually camel.start(); Configuring whether a route should be started or not in XML DSLYou can use the You can disable or enable it as follows: In XML DSL you define it as follows: <route autoStartup="false"> <from uri="activemq:queue:special"/> <to uri="file://backup"/> </route> And to explicit state it should be started <route autoStartup="true"> <from uri="activemq:queue:special"/> <to uri="file://backup"/> </route> Configuring whether a route should be started or not in Java DSLYou can use the You can disable or enable it as follows: from("activemq:queue:special").noAutoStartup().to("file://backup"); Configuring whether a route should be started or not, using a boolean or String, in Java DSLAvailable as of Camel 2.9 To startup based on a boolean, String or Property, do one of the following: boolean startupRoute = true; from("activemq:queue:special").autoStartup(startupRoute).to("file://backup"); ... String startupRoute = "true"; from("activemq:queue:special").autoStartup(startupRoute).to("file://backup"); ... from("activemq:queue:special").autoStartup("{{startupRouteProperty}}").to("file://backup"); Configuring starting order for routesYou can also configure the order in which routes are started. Previously Camel started the routes in a non deterministic order. Now you have fine grained control in which order the routes should be started. There is a new attribute In terms of the Why do you want to control the starting order?It can help in cases where routes are inter dependent on each other and also help with graceful shutting down Camel as Camel can stop the routes in the correct order as well. Stopping routes Camel 2.2: Camel will stop the routes in the same order that they were started. ExamplesLets try a couple of examples Simple examplefrom("seda:foo").startupOrder(1).to("mock:result"); from("direct:start").startupOrder(2).to("seda:foo"); And the same example with XML DSL: <route startupOrder="1"> <from uri="seda:foo"/> <to uri="mock:result"/> </route> <route startupOrder="2"> <from uri="direct:start"/> <to uri="seda:foo"/> </route> In this example we have two routes in which we have started that the You can also mix and match routes with and without Routes with startupOrder mixed with routes withoutfrom("seda:foo").startupOrder(1).to("mock:result"); from("direct:start").startupOrder(2).to("seda:foo"); from("direct:bar").to("seda:bar"); And the same example with XML DSL: <route startupOrder="1"> <from uri="seda:foo"/> <to uri="mock:result"/> </route> <route startupOrder="2"> <from uri="direct:start"/> <to uri="seda:foo"/> </route> <route> <from uri="direct:bar"/> <to uri="seda:bar"/> </route> In the route above we have not define a So you can use this to your advantage to only assign a ShutdownCamel 2.2: Camel will shutdown the routes in the same order that they were started. See also Graceful Shutdown. See also |