【问题标题】:<int-jms:outbound-gateway> is not receiving reply messages<int-jms:outbound-gateway> 未收到回复消息
【发布时间】:2014-07-16 15:07:45
【问题描述】:

我的&lt;int-jms:outbound-gateway&gt; 没有向目标队列发送消息,因此我最终得到了 MessageTimeoutException。

我尝试了完美的工作并发送了确保我在请求通道上收到正确消息的消息。

我还在日志中看到我的出站网关正在接收 requestCh1 上的消息。 org.springframework.integration.jms.JmsOutboundGateway#0 收到消息:[Payload...]

我真的被卡住了,无法弄清楚为什么 jms 出站网关没有将消息发送到目标队列。

有什么帮助吗?

配置:

<int:publish-subscribe-channel id="requestCh1" />

<int:service-activator input-channel="requestCh1" ref="processor" method="processMsg"/>
<bean id="processor" class="com.processor.ProcessorImpl" />

<int-jms:outbound-gateway 
            id="eventPublisherGateway"
            connection-factory="myConnectionFactory"
            request-channel="requestCh1"
            request-destination="qequestQueue"
            reply-channel="responseCh1" 
            reply-destination="responseQueue" 
            receive-timeout="20000">
</int-jms:outbound-gateway>

堆栈跟踪:

07-15-2014 13:18:49 [threaPool.Thread-1] DEBUG AbstractMessageChannel$ChannelInterceptorList.preSend(334) | preSend on channel 'errorChannel', message: [Payload MessageTimeoutException content=org.springframework.integration.MessageTimeoutException: failed to receive JMS response within timeout of: 20000ms][Headers={id=7c81f473-e60e-30fa-b031-8106b3a2fff0, timestamp=1405444729344}]
07-15-2014 13:18:49 [threaPool.Thread-1] DEBUG AbstractMessageHandler.handleMessage(72) | (inner bean)#3dd4a538 received message: [Payload MessageTimeoutException content=org.springframework.integration.MessageTimeoutException: failed to receive JMS response within timeout of: 20000ms][Headers={id=7c81f473-e60e-30fa-b031-8106b3a2fff0, timestamp=1405444729344}]
07-15-2014 13:18:49 [threaPool.Thread-1] ERROR LoggingHandler.handleMessageInternal(145) | org.springframework.integration.MessageTimeoutException: failed to receive JMS response within timeout of: 20000ms
    at org.springframework.integration.jms.JmsOutboundGateway.handleRequestMessage(JmsOutboundGateway.java:667)
    at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:170)
    at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
    at org.springframework.integration.dispatcher.BroadcastingDispatcher.invokeHandler(BroadcastingDispatcher.java:160)
    at org.springframework.integration.dispatcher.BroadcastingDispatcher.dispatch(BroadcastingDispatcher.java:142)
    at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:255)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:223)
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:109)
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:44)
    at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:94)
    at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendMessage(AbstractReplyProducingMessageHandler.java:260)
    at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendReplyMessage(AbstractReplyProducingMessageHandler.java:241)
    at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.produceReply(AbstractReplyProducingMessageHandler.java:205)
    at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleResult(AbstractReplyProducingMessageHandler.java:199)
    at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:177)
    at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
    at org.springframework.integration.endpoint.PollingConsumer.handleMessage(PollingConsumer.java:74)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:205)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:55)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:149)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:146)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:284)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

添加此网关发送的带有相关 ID 的 JMS 消息。

JMS 消息类:jms_text

JMSType:         null
  JMSDeliveryMode: 2
  JMSExpiration:   0
  JMSPriority:     4
  JMSMessageID:    ID:414d5120414344534430513720202020537502dd201b6c02
  JMSTimestamp:    1405462485258
  JMSCorrelationID:bf566441-8ccb-4620-afac-941cc4842a61
  JMSDestination:  queue://QMGR01/REQUESTQ
  JMSReplyTo:      queue://QMGR01/RESPONSEQ
  JMSRedelivered:  false
  JMSXDeliveryCount:0
  JMSXAppID:Websphere MQ Client for Java
  JMS_IBM_PutApplType:28
  timestamp:1405462384810
  sequenceNumber:3
  JMSXUserID:mqcls1      
  sequenceSize:4
  JMS_IBM_PutTime:22574883
  JMS_IBM_PutDate:20140715
<?xml version="1.0" encoding="UTF-8" standalone="no"?><Employee><empId>567</empId></<Employee>

【问题讨论】:

    标签: spring-integration


    【解决方案1】:

    既然你说你得到了MessageTimeoutException,而JmsOutboundGateway中只有一个地方是:

    if (jmsReply == null) {
        if (this.requiresReply) {
            throw new MessageTimeoutException(message,
                    "failed to receive JMS response within timeout of: " + this.receiveTimeout + "ms");
        }
        else {
            return null;
        }
    }
    

    因此您的问题是围绕reply 不请求。 我的意思是你将消息正确地发送到目的地,但对方没有向responseQueue目的地发送回复。

    如果你对request/reply场景不感兴趣,发消息就够了,你可以切换到&lt;int-jms:outbound-channel-adapter&gt;

    如果不是真的,请显示 StackTrace 以查看您的 MessageTimeoutException 是在哪里引起的。

    更新

    这可能是因为 JmsCorrelationId 吗?

    是的,它可以。另一部分必须支持具有来自request 的值的JMSCorrelationID 属性。

    JmsOutboundGateway 通过selector 进行关联:

    messageSelector = "JMSCorrelationID = '" + correlationId + "'";
    ...
    messageConsumer = session.createConsumer(replyTo, messageSelector);
    

    【讨论】:

    • 感谢 Artem 的回复。我删除了我之前的评论,因为在请求队列上发送消息没有被记录,但我签入了实际消息正在发送。我还编写了另一个独立的侦听器容器,在同一个队列上侦听,我的出站网关应该接收回复,并且它会在我发送后立即收到回复。另外我必须使用网关,所以知道我的 有什么问题吗?
    • 请检查主帖中的堆栈跟踪。
    • 如果有independent listener,它会为你的网关窃取消息!因为responseQueueQueue,因此只有一个侦听器可以从队列中获取消息。怎么去掉呢? :-)
    • 我知道,创建独立侦听器只是为了测试,只是为了检查我的消息的接收者是否正在发送回复。当我的 jms 出站网关运行时,我保持独立侦听器关闭。
    • 如果你不控制消费者部分,你不能对correlation做任何事情。正确的。消费者必须使用来自请求的correlationIdreply-destination 发送回复。否则生产者将无法工作。
    猜你喜欢
    • 1970-01-01
    • 2023-04-01
    • 2013-12-18
    • 1970-01-01
    • 1970-01-01
    • 2018-04-24
    • 1970-01-01
    • 2016-07-20
    • 2018-05-15
    相关资源
    最近更新 更多