...
Available as of Camel 2.1
When Camel starts (in fact CamelContext) you can configure how routes should be started
...
Camel now supports configuring two aspects:
- auto startup
- order of starting routes
Configuring whether Camel should be auto started or not
The old option shouldStartContext
have been removed and replaced with this new autoStartup
option instead. What it allows is to configure Camel to not auto start when Spring starts.
For example the route below we have configured autoStartup=false to prevent Camel starting when Spring starts.
Code Block | ||||
---|---|---|---|---|
| ||||
<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 start
method as shown below:
Code Block |
---|
ApplicationContext ac = ...
SpringCamelContext camel = (SpringCamelContext) ac.getBean("myCamel");
// now start Camel manually
camel.start();
|
Configuring whether a route should be started or not
...