I am implementing one Spring Integration work flow as below.
IntegrationFlows.from("inputFileProcessorChannel")
.split(fileSplitterSpec, spec -> {})
.transform(lineItemTransformer)
.handle(httpRequestExecutingMessageHandler)
.transform(reportDataAggregator)
.aggregate(aggregatorSpec -> aggregatorSpec.requiresReply(false))
.channel("reportGeneratorChannel")
.get();
Now, once the above flow is completed, I need to move the input file
to a archive directory. The decision to decide on the destination directory is based on a message header processingFailed
and this header is added in .transform(reportDataAggregator)
step in the flow. To move this files I have create another flow as in below code
IntegrationFlows.from(MessageChannels.direct("inputFileProcessorChannel"))
.routeToRecipients(routerSpec -> {
routerSpec.recipient("processedFileMoverChannel", createMessageSelector(Boolean.FALSE))
.recipient("failedFileMoverChannel", createMessageSelector(Boolean.TRUE));
})
.get();
Selector method
private MessageSelector createMessageSelector(Boolean ruleBoolean) {
return message -> ruleBoolean.equals(message.getHeaders().get("processingFailed"));
}
Report Channel flow below
IntegrationFlows.from("reportGeneratorChannel")
.transform(executionReportTransformer)
.handle(reportWritingMessageHandlerSpec)
.get();
But, as expected with this flow, File movement is not done as the said header is not present into the flow execution.
So, How to achieve this goal to Execute the file mover flow
after the report file is created?