Spring 将 jmsmessage-driven-channel-adapter 与 IBM MQ 集成

Spring Integration jmsmessage-driven-channel-adapter with IBM MQ

我已经使用 Spring Integration JMS-message-driven-channel-adapter 编写了代码来读取来自 IBM MQ 的消息,但无法从队列中读取消息,任何人都可以帮助我,下面是我的配置。

<beans:bean id="ibmJmsConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
    <beans:property name="transportType" value="1"/>
    <beans:property name="queueManager" value="***"/>
    <beans:property name="hostName" value="**"/>
    <beans:property name="port" value="**" />
    <beans:property name="channel" value="***"/>
</beans:bean>


<beans:bean id="receiverQueue" class="com.ibm.mq.jms.MQQueue">
    <beans:constructor-arg index="0" value="****"/>
    <beans:constructor-arg index="1" value="****"/>
</beans:bean>
<integration:channel id="componentInfoChannel" />

 <jms:message-driven-channel-adapter
        id="componentInfoAdapter" connection-factory="ibmJmsConnectionFactory" destination="receiverQueue" channel="componentInfoChannel" 
         />

<integration:service-activator id="componentInfoActivator"
        input-channel="componentInfoChannel" ref="componentInfoConsumer"
        method="componentInfoListen" />

以上配置有效,但当我添加日志记录适配器时失败,它在控制台上不断打印警告。详情如下所述。

<integration:logging-channel-adapter
        id="componentInfologger" level="INFO" />
    <integration:wire-tap id="componentInfoWireTap"
        channel="componentInfologger" pattern="*" order="2" />
    <integration:logging-channel-adapter
        id="logger" log-full-message="true" level="INFO" />

   2017-02-23 00:09:05.093  WARN [componentdatafiles,48f69e84ab395754,ebf4ae7f3b812a01,false] 90072 --- [ter.container-1] o.s.j.l.DefaultMessageListenerContainer  :  Execution of JMS message listener failed, and no ErrorHandler has been set.
java.lang.WhosebugError: null
    at java.util.Collections$SynchronizedMap.put(Unknown Source)
    at ch.qos.logback.classic.util.LogbackMDCAdapter.put(LogbackMDCAdapter.java:110)
    at org.slf4j.MDC.put(MDC.java:147)
    at org.springframework.cloud.sleuth.log.Slf4jSpanLogger.logStartedSpan(Slf4jSpanLogger.java:48)
    at org.springframework.cloud.sleuth.trace.DefaultTracer.createChild(DefaultTracer.java:170)
    at org.springframework.cloud.sleuth.trace.DefaultTracer.createSpan(DefaultTracer.java:72)
    at org.springframework.cloud.sleuth.instrument.messaging.TraceChannelInterceptor.startSpan(TraceChannelInterceptor.java:98)
    at org.springframework.cloud.sleuth.instrument.messaging.TraceChannelInterceptor.preSend(TraceChannelInterceptor.java:78)
    at org.springframework.integration.channel.AbstractMessageChannel$ChannelInterceptorList.preSend(AbstractMessageChannel.java:538)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:415)
    at org.springframework.integration.channel.interceptor.WireTap.preSend(WireTap.java:168)
    at org.springframework.integration.channel.AbstractMessageChannel$ChannelInterceptorList.preSend(AbstractMessageChannel.java:538)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:415)
    at org.springframework.integration.channel.interceptor.WireTap.preSend(WireTap.java:168)
    at org.springframework.integration.channel.AbstractMessageChannel$ChannelInterceptorList.preSend(AbstractMessageChannel.java:538)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:415)
    at org.springframework.integration.channel.interceptor.WireTap.preSend(WireTap.java:168)
    at org.springframework.integration.channel.AbstractMessageChannel$ChannelInterceptorList.preSend(AbstractMessageChannel.java:538)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:415)
    at org.springframework.integration.channel.interceptor.WireTap.preSend(WireTap.java:168)

抱歉耽搁了。所以,我猜你的 id="logger" 是多余的组件。而问题恰恰在于 <integration:wire-tap> 以及与 TraceChannelInterceptor 的组合。

我的意思是你在这里使用 Spring Cloud Sleuth。

你介意分享 DEBUGorg.springframework.integration 类别,同时我正在尝试在本地重现问题。

此外,您可以从跟踪中排除 componentInfologger 以避免 java.lang.WhosebugError

我认为我们通过 wire-tap.

进行循环跟踪