Spring boot IBM MQ忽略由Camel+;基于Spring引导的应用程序
我们开发了一个基于ApacheCamel JMS组件和Spring Boot的微服务。IBM MQ用作消息传递中间件。异常侦听器存在问题-当与MQ的连接中断时,IBM MQ类无法找到已注册的异常侦听器并在system out中打印它自己的堆栈跟踪:Spring boot IBM MQ忽略由Camel+;基于Spring引导的应用程序,spring-boot,apache-camel,ibm-mq,Spring Boot,Apache Camel,Ibm Mq,我们开发了一个基于ApacheCamel JMS组件和Spring Boot的微服务。IBM MQ用作消息传递中间件。异常侦听器存在问题-当与MQ的连接中断时,IBM MQ类无法找到已注册的异常侦听器并在system out中打印它自己的堆栈跟踪: com.ibm.msg.client.jms.internal.JmsProviderExceptionListener The exception is ignored as no exception listener is registered:
com.ibm.msg.client.jms.internal.JmsProviderExceptionListener
The exception is ignored as no exception listener is registered: '
Message : com.ibm.msg.client.jms.DetailedJMSException: JMSWMQ1107: A problem with this connection has occurred.
An error has occurred with the IBM MQ JMS connection.
Use the linked exception to determine the cause of this error.
org.springframework.jms.connection.CachingConnectionFactory
用于连接设置
@Bean
protected final ConnectionFactory createMqJmsConnectionFactory() {
MQQueueConnectionFactory mqFactory = new MQQueueConnectionFactory();
// Factory setup
CachingConnectionFactory cachingFactory = new CachingConnectionFactory(mqFactory);
return cachingFactory;
}
CachingConnectionFactory
的祖先实现了javax.jms.ExceptionListener
,正如我在Spring论坛上发现的那样,它将自己注册为ExceptionListener。从堆栈跟踪中,我可以看到在异常之后调用onException()
方法,重置连接并写入日志
因此,当IBM MQ忽略CachingConnectionFactory
作为异常侦听器时,就会出现这种情况。Camel JMS组件具有exceptionListener
endpoint配置选项-我假设在这里添加CachingConnectionFactory
将是冗余的
要将
CachingConnectionFactory
注册为异常侦听器,需要执行任何其他设置?尝试在端点配置中添加exceptionListener
,即使它看起来是冗余的。或者通过调用cachingFactory.setExceptionListener(cachingFactory)
在上述@Bean
定义中将对象本身添加为exceptionListener
。根据您在spring论坛上读到的内容,它可能看起来是多余的,但尝试这样做将确保您的ExceptionListener
已实际设置,而不是假设。尝试在端点配置中添加ExceptionListener
,即使它看起来是多余的。或者通过调用cachingFactory.setExceptionListener(cachingFactory)
在上述@Bean
定义中将对象本身添加为exceptionListener
。根据您在spring论坛上所读到的内容,它可能看起来有些多余,但尝试这样做将确保您的例外侦听器实际上已设置,而不是一个假设。