【问题标题】:Spring Integration JMS Gateway without reply listener没有回复监听器的 Spring Integration JMS Gateway
【发布时间】:2016-02-03 20:54:35
【问题描述】:

我在以下案例中遇到了 Spring Integration 的挑战。

同一个应用程序(Spring Integration)在多台服务器上运行, 对于 JMS(出站),我使用的是 jms:outbound-channel-adapter,但检查出站网关我注意到有用于调整 JMS 队列的参数(启用显式 qos、生存时间和依此类推),但问题是“回复侦听器”,因为应用程序在连接到其他服务器(其他网关)的多个服务器上运行,回复消息可以由不是发送 JMS 的服务器的其他服务器处理信息。

我的疑问是如何在没有任何“回复侦听器”的情况下配置“出站网关”,这意味着没有配置“回复侦听器”(预创建的 since 都不会创建一个可能永远不会收到回复并会持有的线程一个线程(监听线程)没有任何理由)。

阅读文档我了解到这是不可能的。 这是真的吗?好像没有“回复侦听器”就无法使用出站网关?

【问题讨论】:

    标签: java multithreading spring jms spring-integration


    【解决方案1】:

    让我稍微引用一​​下JmsOutboundGateway源代码:

    if (logger.isWarnEnabled()) {
        logger.warn("The gateway cannot use a reply listener container with a specified destination(Name/Expression) " +
                    "without a 'correlation-key'; " +
                    "a container will NOT be used; " +
                    "to avoid this problem, set the 'correlation-key' attribute; " +
                    "some consumers, including the Spring Integration <jms:inbound-gateway/>, " +
                    "support the use of the value 'JMSCorrelationID' " +
                    "for this purpose. Alternatively, do not specify a reply destination " +
                    "and a temporary queue will be used for replies.");
        }
    

    稍后在handleRequestMessage:

    if (this.replyContainer == null) {
        jmsReply = this.sendAndReceiveWithoutContainer(requestMessage);
    }
    

    因此,您可以使用 &lt;int-jms:outbound-gateway&gt; 而不使用 reply-listener。 像这样的:

    <int-jms:outbound-gateway request-destination="requestQueueA" 
                                  reply-destination="replyQueueB" 
                                  connection-factory="connectionFactory"/>
    

    【讨论】:

    • 那么设置回复目的地,“reply-listener”不会被创建?我怀疑临时队列既不应该创建回复侦听器。并设置回复目的地会将其添加到 JMS 标头中,如果我有 300 个队列和另外 300 个回复队列,则配置非常冗长。 (实际上 JMS 配置就是这样的)。问候。
    • 是的,它依赖于consumerSession.createConsumer(replyTo, messageSelector);
    • 我会测试并检查会发生什么。谢了。
    • 即使在使用回复监听器时;每个网关只会看到它自己的回复 - 网关使用消息选择器只使用对它发起的请求的回复。
    猜你喜欢
    • 2019-07-20
    • 1970-01-01
    • 2017-01-23
    • 2023-03-26
    • 2012-06-30
    • 1970-01-01
    • 1970-01-01
    • 2022-12-01
    • 1970-01-01
    相关资源
    最近更新 更多