0
votes

I have two jms:inbound gateways listening to two different queuemanagers/queue but sharing the same inbound/error/outbound channel. Once the message is picked up and processed the gateway has to respond based on the JMSReplyTo header(processing is the same way its just that we have queuemanagers on different hosts). Since the outbond channel is same, how will the gateways differentiate between which response queue to send. So question is does the gateways maintain its own instance of the channels? If not should I have different set of inbound/error/outbound channels for both the gateways so that the sender gets the correct response or is there a better solution. Please advice.

<int-jms:inbound-gateway id="test1"
    request-channel="inbouldChannel"
    reply-channel="outboundChannel"
    error-channel="errorChannel"
    header-mapper="headerMapper"
    container="listenerContainer1"/>

<int-jms:inbound-gateway id="test2"
    request-channel="inbouldChannel"
    reply-channel="outboundChannel"
    error-channel="errorChannel"
    header-mapper="headerMapper"
    container="listenerContainer2"/>
1

1 Answers

1
votes

They use the same request channel instance; but they add a unique temporary reply channel in the replyChannel header for each message.

You should omit the reply-channel attribute on the gateways and don't supply an output-channel on the last endpoint that processes the message. The framework will then use the header to route the reply to the right gateway.

Even with your configuration, it will actually work (because ultimately it's bridged to the header channel in whichever gateway receives the reply) but it looks weird having the same reply-channel on both gateways.

The cleanest solution is to just omit the attribute and let the framework take care of the routing.