我在我的应用程序中使用camel,我想创建一个SmartLifeCycle bean,它在CamelContext之前开始。
为了做到这一点,我实现了一个定制的SmartLifeCycle bean,其阶段为: Integer.MAX_VALUE - 101。SpringCamelContext有一个阶段为: Ordered.LOWEST_PRECEDENCE
在我的电脑上- SpringCamelContext。
但是,一旦我在服务器上部署,SpringCamelContext就会在以前启动。
知道为什么吗?我怎样才能确保我的豆子在开始之前就开始了呢?
谢谢
编辑
SpringCamelContext似乎是一个"LifeCycle“bean,而不是"SmartLifeCycle”bean。根据文件:
<p>Any {@code Lifecycle} components within the context that do not also
implement {@code SmartLifecycle} will be treated as if they have a phase
value of 0. That way a {@code SmartLifecycle} implementation may start
before those {@code Lifecycle} components if it has a negative phase value,
or it may start after those components if it has a positive phase value.但我仍然不知道如何解决这个问题(我如何知道使用负值不会产生某种副作用)?为什么它在我的本地电脑上工作?
编辑2:
不同之处在于管理结构。如果我对管理端口使用不同的端口,并且使用另一个配置: DifferentManagementContextConfiguration。
在启动时,在配置中调用"afterSingletonsInstantiated()“方法,并创建一个立即刷新的managementContext。
此上下文在主ApplicationContext刷新之前和启动LifeCycleProcessor之前刷新。
由于其中的SpringCamelContext侦听器,此刷新正在初始化ContextRefreshedEvent。
我还在找能解决这个问题的东西..。
发布于 2019-07-01 16:19:20
这是一个已知的错误,已在2.24.1骆驼版本中修复。
https://stackoverflow.com/questions/56833590
复制相似问题