首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使SmartLifeCycle bean在SpringCamelContext之前启动?

如何使SmartLifeCycle bean在SpringCamelContext之前启动?
EN

Stack Overflow用户
提问于 2019-07-01 09:57:04
回答 1查看 143关注 0票数 0

我在我的应用程序中使用camel,我想创建一个SmartLifeCycle bean,它在CamelContext之前开始。

为了做到这一点,我实现了一个定制的SmartLifeCycle bean,其阶段为: Integer.MAX_VALUE - 101。SpringCamelContext有一个阶段为: Ordered.LOWEST_PRECEDENCE

在我的电脑上- SpringCamelContext。

但是,一旦我在服务器上部署,SpringCamelContext就会在以前启动。

知道为什么吗?我怎样才能确保我的豆子在开始之前就开始了呢?

谢谢

编辑

SpringCamelContext似乎是一个"LifeCycle“bean,而不是"SmartLifeCycle”bean。根据文件:

代码语言:javascript
复制
 <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。

我还在找能解决这个问题的东西..。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-01 16:19:20

这是一个已知的错误,已在2.24.1骆驼版本中修复。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56833590

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档