By default, all of the routes in a CamelContext will be
started automatically. If you want to control the start-up of a particular route manually,
however, you might prefer to disable automatic start-up for that route.
As shown in Example 10.1, you can disable automatic start-up
of a route in the by setting its autoStartup attribute to
false.
Example 10.1. Disabling route auto start up
<camelContext id="CamelContextID" xmlns="http://camel.apache.org/schema/spring"> <route id="nonAuto" autoStartup="false"> <from uri="SourceURI"/> <to uri="TargetURI"/> </route> </camelContext>
You can manually start a route at any time in Java by invoking the
startRoute() method on the CamelContext
instance. For example, to start the route having the route ID,
nonAuto, invoke the startRoute() method on the
CamelContext instance, context, as follows:
context.startRoute("nonAuto");By default, Apache Camel starts up routes in a non-deterministic order. In some
applications it can be important to control the startup order. To control the startup
order you use the startupOrder attribute, which takes a
positive integer value. The route with the lowest integer value starts first, followed
by the routes with successively higher startup order values.
The first two routes in Example 10.2 are linked together
through the seda:buffer endpoint. You can ensure that the first route segment
starts after the second route segment by assigning startup
orders.
Example 10.2. Startup order
<route id="first" startupOrder="2"> <from uri="jetty:http://fooserver:8080"/> <to uri="seda:buffer"/> </route> <route id="second" startupOrder="1"> <from uri="seda:buffer"/> <to uri="mock:result"/> </route> <!-- This route's startup order is unspecified --> <route> <from uri="jms:queue:foo"/> <to uri="jms:queue:bar"/> </route>
Each route must be assigned a unique startup order value. You can choose any positive integer value that is less than 1000. Values of 1000 and over are reserved for Apache Camel, which automatically assigns these values to routes without an explicit startup value. For example, the last route in the preceding example would automatically be assigned the startup value 1000.








