Multiple channel's message comes into single c

2020-08-04 11:43发布

问题:

i am fresher of Spring Integration, i am confuing one question which i have multiple channels but now i want to assemble messages from those channel into single channel, how to implement it ? my senario is that i have lots of businees modues and each module will corresponding to one channel, those channels will receive the request then assemble the message into one single channel , then output to the jms server:

is below code possible ?

<channel id='a'/> <bridge input-channel='a' out-channel='assembled'/>
<channel id='b'/> <bridge input-channel='b' out-channel='assembled'/>
<channel id='b'/> <bridge input-channel='c' out-channel='assembled'/>
<channel id='c'/> <bridge input-channel='d' out-channel='assembled'/>

<channel id='assembled'/>

<!-- the router will desicde which jms gateway to be sent  -->
<router input-channel='assembled' > 

<channel id='to_jms1'/>
<channel id='to_jms2'/>

<jms-outbound-gateway id='jms1' channel='to_jms1'/>
<jms-outbound-gateway id='jms2' channel='to_jms2'/>

回答1:

If you mean you want to send each individual message arriving on a, b, c etc to the same channel, then what you have above will work.

If you want to merge together the messages on a, b, c, d into a single message then after the bridges, use an <aggregator/> with appropriate correlation and release strategies.

See the reference documentation for more information.