...
Using a spring bean we just declare the route builder using a regular spring bean:
Code Block | ||||
---|---|---|---|---|
| ||||
<bean id="myrouter" class="org.apache.camel.example.reportincident.ReportIncidentRoutes"/>
|
And then we can refer to it from our CamelContext:
Code Block | ||||
---|---|---|---|---|
| ||||
<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
<routeBuilderRef ref="myrouter"/>
</camelContext>
|
So now when Spring start's it will read the camel-context.xml file and thus also start Camel as well. As SpringCamelContext is spring lifecycle event aware, Camel will also shutdown when Spring is shutting down. So when you stop the web application Spring will notify this and Camel is also shutdown nice and properly. So as an end user no need to worry.