首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >apache camle jms组件中的exceptionListener和errorHandler,对我不起作用。

apache camle jms组件中的exceptionListener和errorHandler,对我不起作用。
EN

Stack Overflow用户
提问于 2014-05-14 06:02:16
回答 2查看 1.6K关注 0票数 1

我使用apache camel Jms组件通过以下代码和配置连接到IBM MQ。如果MQ管理器在消息轮询期间因任何原因关闭,或者在camel路由启动时关闭,则不会调用我的errorHandler或exceptionListener。

代码语言:javascript
复制
jmsComponenet = JmsComponent.jmsComponentAutoAcknowledge((ConnectionFactory) obj);
camelContext.addComponent("ibm-mq", jmsComponenet);
camelContext.addRoutes(new RouteBuilder() {
   @Override
   public void configure() throws Exception {
    from("ibm-mq:queue:PE_OUTBOUND?concurrentConsumers=5&exceptionListener=#exceptionListener&errorHandler=#errorHandler").to(
                            "mqprocessor"); 
   }

});

Spring应用程序-上下文:

代码语言:javascript
复制
<bean id="exceptionListener" class="com.*****.JMSExceptionListener" />
<bean id="errorHandler" class="com.*****.JMSConnectionErrorHandler" />

类实现了所需的接口

javax.jms.ExceptionListenerorg.springframework.util.ErrorHandler

尽管指定了Handler和Listener,MQ连接错误仍然被记录为日志中的WARN消息,并且controll没有到达这些类。

我在这里缺少/做错了什么吗?

这是调试日志-

代码语言:javascript
复制
11:18:20,783 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] (http-localhost/127.0.0.1:8080-1) Returning cached instance of singleton bean 'errorHandler'
11:18:20,784 DEBUG [org.apache.camel.util.IntrospectionSupport] (http-localhost/127.0.0.1:8080-1) Configured property: errorHandler on bean: org.apache.camel.component.jms.JmsConfiguration@17b86db4 with value: com.manh.processors.JMSConnectionErrorHandler@4d2a5096
11:18:20,784 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] (http-localhost/127.0.0.1:8080-1) Returning cached instance of singleton bean 'exceptionListener'
11:18:20,784 DEBUG [org.apache.camel.util.IntrospectionSupport] (http-localhost/127.0.0.1:8080-1) Configured property: exceptionListener on bean: org.apache.camel.component.jms.JmsConfiguration@17b86db4 with value: com.manh.processors.JMSExceptionListener@6c8b8e49
11:18:20,785 DEBUG [org.apache.camel.spring.SpringCamelContext] (http-localhost/127.0.0.1:8080-1) ibm-mq://queue:PE_OUTBOUND?concurrentConsumers=5&errorHandler=%23errorHandler&exceptionListener=%23exceptionListener converted to endpoint: Endpoint[ibm-mq://queue:PE_OUTBOUND?concurrentConsumers=5&errorHandler=%23errorHandler&exceptionListener=%23exceptionListener] by component: org.apache.camel.component.jms.JmsComponent@fb03c67
11:18:20,785 TRACE [org.apache.camel.management.DefaultManagementLifecycleStrategy] (http-localhost/127.0.0.1:8080-1) Checking whether to register Endpoint[ibm-mq://queue:PE_OUTBOUND?concurrentConsumers=5&errorHandler=%23errorHandler&exceptionListener=%23exceptionListener] from route: null
EN

回答 2

Stack Overflow用户

发布于 2014-05-15 04:50:32

默认testConnectionOnStartup = false。我将它设置为ture,并且在路由启动时得到异常。

只有在处理消息的过程中出现异常时,ErrorHandler才会起作用。

丹尼尔,谢谢你的帮助。

票数 2
EN

Stack Overflow用户

发布于 2014-05-14 16:12:32

当找不到错误处理程序时,默认情况下使用warn消息进行日志记录,因此我怀疑Camel无法找到所提供的bean的实例。尝试将camel日志级别设置为debug,并查看路由启动时显示的内容,我希望看到某种消息,指出找不到引用的bean。

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

https://stackoverflow.com/questions/23642348

复制
相关文章

相似问题

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