0
votes

I have the following requirement: A message could come in on one of several message-driven-channel-adapter definitions, all obviously mapped to different incoming queues.

All the channel adapters then forward to the same internal Spring Integration channel where they are handled.

How can it be determined exactly which channel adapter - and therefore queue - the message was received on? For instance, is there a way in the channel adapter configuration to specify that a property be added to the message header at that point, which would be one solution. Thanks

2

2 Answers

1
votes

One way to do it is to write a ChannelInterceptor to add a header to the message. The preSend() method provides the Message and MessageChannel as arguments. MessageChannel may be cast to NamedComponent (An interface implemented be AbstracMessageChannel) to get the channel name.

0
votes

You can use a header enrichier with a different identifier after each message-driven-channel-adapter.

For example :

<jms:message-driven-channel-adapter id="jmsIn1" destination="inQueue1" channel="in1"/>
<int:header-enricher input-channel="in1" output-channel="out1">
     <int:header name="fromAdapter" value="1"/>
</int:header-enricher>

<jms:message-driven-channel-adapter id="jmsIn2" destination="inQueue2" channel="in1"/>
<int:header-enricher input-channel="in2" output-channel="out2">
     <int:header name="fromAdapter" value="2"/>
</int:header-enricher>