作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您能否提供最简单的示例,我如何将自定义 LifecycleStrategySupport 应用于
1. Camel xml上下文
2. java Camel 上下文
更准确地说,我需要有多个 Camel 上下文(在单个 Spring 上下文中),并仅将自定义生命周期策略应用于其中一个。
最佳答案
使用以下代码可以轻松地将自定义 LifecycleStrategySupport 设置到 Camel 上下文。
MyLifecycleStrategy dummy1 = new MyLifecycleStrategy();
CamelContext context = new DefaultCamelContext();
context.addLifecycleStrategy(dummy1);
如果使用spring配置,应用程序中定义的LifecycleStrategy将直接注入(inject)camelcontext。在处理生命周期事件之前,您可能需要检查自定义 LifecycleStrategy 中的camelcontext id。
<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>
关于java - 如何将自定义 LifecycleStrategySupport 应用于 Camel 上下文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25767741/
您能否提供最简单的示例,我如何将自定义 LifecycleStrategySupport 应用于 1. Camel xml上下文 2. java Camel 上下文 更准确地说,我需要有多个 Came
我是一名优秀的程序员,十分优秀!