1
votes

Is it possible in spring integration to send child records of one master record to multiple slaves in jms backed queue and aggregate their response in master node and once all childs being process update something in db?

1

1 Answers

0
votes

It not generally recommended to use jms-backed channels to distribute work to other instances; use channel adapters instead. JMS-backed channels are really for persistence, not distribution.

Put an jms outbound channel adapter after the splitter.

Master

... ->splitter->jms:outbound-channel-adapter

jms:message-driven-channel-adapter->aggregator-> ...

Slaves

jms:message-driven-channel-adapter-> ... ->jms:outbound-channel-adapter

If you want to route the reply from the aggregator back to the original caller, you will need to retain the replyChannel - since they are live objects, they don't survive serialization so you will need to use a header enricher upstream of the splitter, to add the reply channel to the channel registry and convey the reply channel as a String over JMS.

You will also need to add a header to tell the slave which destination name to send the result to; you can do that in the same header enricher. On the slave side, use a destination-expresssion on the outbound adapter.