简体   繁体   中英

Spring Integration JMS Gateway without reply listener

I'm having a challenge with Spring Integration with the following case.

Same application (Spring Integration) is running on several servers, For JMS (outbound) I am using the jms:outbound-channel-adapter, but checking the outbound gateway i notice that there has the parameters that is used to tune the JMS Queue (explicit-qos-enabled, time-to-live and so on), but the problem is the "reply-listener", since the application is running on several servers connected to other servers (other gateways), the reply message can be processed by other server that is not the server that sent the JMS message.

My doubt is how to configure the "outbound-gateway" without any "reply-listener", which means no "reply-listener" configured (neither the precreated since will create a thread that maybe never receive the reply and will hold a thread (listener thread) without any reason).

Reading the documentation I understood that this is not possible. Is it true? like there are no way to use the outbound gateway without the "reply-listener"?

Let me just quote the JmsOutboundGateway source code a bit:

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.");
    }

And a bit later in the handleRequestMessage :

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

So, you can use <int-jms:outbound-gateway> without reply-listener . Something like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM