jmsspring-integrationgatewayinbound

How to intercept the reply message of an jms inbound gateway


I have a jms-inbound-gateway that reads requests from a WebsphereMQ broker, passes them though my integration system and then replies with a response message.

I need to log the messages with the jms_messageId and jms_correlationId headers set, so I can match request/reply messages in the log file (and show it to my client when he says that my response does not have the correct jms_correlationId)

Is there a way to intercept the method producer.sendReply(...) after the correlationId header is set?


Solution

  • There is no need to intercept there; the headers are available in the Spring Integration messsage in the gateway reply message before it gets to the gateway.

    Simply make the reply-channel a publish-subscribe-channel and add a <logging-channel-adapter/> that has it as its input channel.

    The reply message will be sent to both the gateway and the logger.

    If you are using the default mechanism to route the reply (no output-channel on your last integration component), simply add an output-channel and route to the reply channel.