java - 如何获取默认的 apache camel 上下文 id 或创建新的

标签 java spring apache error-handling javabeans

我对基于 apache camel 的应用程序有疑问。我的模块很少。在他们每个人中,我都有在 xml 文件中定义的 Camel 路线,如下所示:

<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')在 Camel 上下文停止之前关闭。我在 apache camel 论坛上关注了一些类似的问题,人们建议设置取决于我在 Camel 中使用的 bean 上的参数('myErrorHandler' bean),如下所示:

http://camel.465427.n5.nabble.com/quot-Singleton-bean-creation-not-allowed-while-the-singletons-of-this-factory-are-in-destruction-quon-td5713684.html

http://camel.465427.n5.nabble.com/Spring-destroys-camelTemplate-before-CamelContext-td5464452.html

但在我的情况下,我的 xml 中没有 camelContext 元素(如我所示,我只有“路由”元素),因此很难在我的 bean 中设置依赖于 Camel 上下文 id。

任何想法如何解决这个问题?也许我可以在其他地方设置全局camelContext id并在我的bean定义中使用它?在此先感谢您的帮助。

最佳答案

只能在从 Camel 2.3 开始的新 标记中定义 之外的路由。
引用自:http://camel.apache.org/configuring-camel.html

您仍然需要 camelContext 来配置您的路线。所以我的猜测是你的路由 xml 被导入到一些常见的 xml 中,这些 xml 将具有 comeContext。
只需搜索并使用它。

关于java - 如何获取默认的 apache camel 上下文 id 或创建新的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34530175/

相关文章:

php - (12)无法分配内存: couldn't create child process:/opt/suphp/sbin/suphp

java - 如何使用反射获取嵌套类属性的值?

java - W/System.err : java.net.SocketException:套接字已关闭

java - 智能理念 | xml验证错误

java - Spring MVC RestController 作用域

java - 如何阻止 spring-bootembedded-undertow 添加尾部斜杠

java - 使用 Java 进行 JWT Token 验证

java - 无法从 Spring-Jersey 中检索安全上下文

html - 在 Rails 应用程序中设置字符集

regex - 如何将 www 加入到非 www 重写规则与现有