Reputation: 20986
Could you please provide simplest examples how could I apply custom LifecycleStrategySupport to
1. camel xml context
2. java camel context
To be more exact I need to have several camel contexts (within single Spring context), and apply custom lifecycle strategy to only one of them.
Upvotes: 0
Views: 833
Reputation: 3291
It's easy to setup the custom LifecycleStrategySupport to the camel context with below code.
MyLifecycleStrategy dummy1 = new MyLifecycleStrategy();
CamelContext context = new DefaultCamelContext();
context.addLifecycleStrategy(dummy1);
If you use spring configuration, the LifecycleStrategy which is defined in the application will be inject the camelcontext directly. You may need to check the camelcontext id in your custom LifecycleStrategy before handling the lifecycle event.
<bean id="lifecycleStrategy" class="org.apache.camel.spring.DummyLifecycleStrategy"/>
<camelContext id="camel1" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:start"/>
<to uri="mock:result"/>
</route>
Upvotes: 3