0
votes

I am trying to send reply Q details in the JMS Header when using Outbound Gateway in spring integration. I learnt that enhances made in JIRA #INT-97 copies the spring message headers to JMS headers before sending it to the JMS destination.

Before sending the message to the outbound gateway, set the message header as below. message.getHeader().setAttribute(JmsTargetAdapter.JMS_REPLY_TO, myReplyDestination);

But I am not able to find the JmsTargetAdapter class in any of the SI jars.

Can anybody help me out with the jar that has this class?

Also, Is my below understanding correct?

  1. Enrich your message header with the JMSReplyTo attribute which has an MQQueue object (I'm sending messages to MQ)
  2. Post the message using outbound gateway (by default, the JMS Headers will be appended with the SI headers)

EDIT:

I have source and destination systems where source sends request to a MQ broker eg: MQBroker 1 and destination sends back the reply to MQBroker 2. Both the brokers are interconnected through middleware layer.

I need to pass the reply Q and Q Manager details in the request header for the destination to put back the reply. But the reply Q details are residing in Broker 2 whereas the outbound gateway configs will have the Broker 1 configuration.

How to achieve this with Outbound gateway? Is this possible?

1

1 Answers

1
votes

That is a very old issue from a very, very, old pre-release of the framework.

See the current documentation about how to use the outbound gateway.

You don't need to set up the headers that way; configure one of the reply-destination* attributes on the gateway.

EDIT

In reply to your comment:

The gateway cannot talk to two different brokers. You would have to use outbound and inbound channel adapters for that, and do your own reply correlation.

To do that, you could use a header enricher to set the jms_replyTo header...

<int:header-enricher>
    <int:header name="jms_replyTo" ref="someReplyDestination" />
    <int:header name="jms_correlationId" expression="headers['id'].toString()" />
</int:header-enricher>

...where someReplyDestinaion is a <bean/> representing your vendor's queue object. The second header will set the JMSCorrelationId. (Or you can use your own correlation mechanism).

The JMSCorrelationID in the reply will be in header jms_correlationId.

As long as the server echoes back the same correlation id, you will be able to match the reply with the request; either in your own code, or with an aggregator.