I have a Spring Integration app that puts incoming files onto a channel. From there I’d like to be able to send the same file to two different processing pipelines (one archiving to S3, another parsing the contents) and later have a downstream component that can recognise when both have been successfully processed, and thus delete the actual local file.
The semantics are like if I needed a Splitter/Aggregator, but instead of splitting the message I need to duplicate it.
Is there any way to achieve this with available components, or will it require some custom classes?
Yes, a
<publish-subscribe-channel/>(withapply-sequence="true") will work similarly to a splitter – however both subscribers to the channel will get the SAMEFileobject. By default the two branches will be executed serially but you can introduce an ExecutorChannel if you want to process in parallel.If you want each subscriber to get a different
Fileobject, you could add a transformer…<transformer ... expression="new java.io.File(payload.absolutePath)" />