我使用apache camel Jms组件通过以下代码和配置连接到IBM MQ。如果MQ管理器在消息轮询期间因任何原因关闭,或者在camel路由启动时关闭,则不会调用我的errorHandler或exceptionListener。
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应用程序-上下文:
<bean id="exceptionListener" class="com.*****.JMSExceptionListener" />
<bean id="errorHandler" class="com.*****.JMSConnectionErrorHandler" />类实现了所需的接口
javax.jms.ExceptionListener和org.springframework.util.ErrorHandler
尽管指定了Handler和Listener,MQ连接错误仍然被记录为日志中的WARN消息,并且controll没有到达这些类。
我在这里缺少/做错了什么吗?
这是调试日志-
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发布于 2014-05-15 04:50:32
默认testConnectionOnStartup = false。我将它设置为ture,并且在路由启动时得到异常。
只有在处理消息的过程中出现异常时,ErrorHandler才会起作用。
丹尼尔,谢谢你的帮助。
发布于 2014-05-14 16:12:32
当找不到错误处理程序时,默认情况下使用warn消息进行日志记录,因此我怀疑Camel无法找到所提供的bean的实例。尝试将camel日志级别设置为debug,并查看路由启动时显示的内容,我希望看到某种消息,指出找不到引用的bean。
https://stackoverflow.com/questions/23642348
复制相似问题