【发布时间】:2015-12-30 13:07:25
【问题描述】:
我对基于 apache camel 的应用程序有疑问。我的模块很少。在他们每个人中,我都有在 xml 文件中定义的骆驼路线,如下所示:
<routes xmlns="http://camel.apache.org/schema/spring">
<route id="..." errorHandlerRef="myErrorHandler">
...
</route>
other routes...
</routes>
应用程序运行良好。但是当我的应用程序关闭时,我收到了警告:
org.apache.camel.RuntimeCamelException: org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'myErrorHandler': Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
可能我收到此警告是因为 spring bean(在本例中为“myErrorHandler”)在骆驼上下文停止之前关闭。我在 apache camel 论坛上关注了一些类似的问题,人们建议设置取决于我在骆驼中使用的 bean 上的参数('myErrorHandler' bean),如下所示:
http://camel.465427.n5.nabble.com/Spring-destroys-camelTemplate-before-CamelContext-td5464452.html
但在我的情况下,我的 xml 中没有 camelContext 元素(如我所示,我只有 'routes' 元素),因此很难在我的 bean 中设置依赖于骆驼上下文 id。
任何想法如何解决这个问题?也许我可以在其他地方设置全局camelContext id并在我的bean定义中使用它?提前感谢您的帮助。
【问题讨论】:
-
您的 xml 是其他一些常见 xml 的一部分?路线总是在骆驼上下文中定义的。您的应用程序肯定会有至少一个骆驼上下文。
标签: java spring apache error-handling javabeans