I have a SFTP Adapter it download the file from remote location and transform it . However its skipping the alternate file. i.e if in SFTP HOST files are 1.zip,2.zip,3.zip ,Then it only process 1.zip and 3.zip
@Bean
@Primary
public IntegrationFlow sftpInboundFlow(){
...
..
SftpInboundChannelAdapterSpec messageSourceBuilder =
...
..
IntegrationFlowBuilder flowBuilder = IntegrationFlows
.from(messageSourceBuilder, consumerSpec())
.log(Level.INFO, m -> "INBOUND: " + m.getPayload() + " HEADERS: " + m.getHeaders()
);
return flowBuilder.channel(INBOUND_CHANNEL).handle(new MessageHandler());
// Works fine if changed to
// flowBuilder.channel(INBOUND_CHANNEL).get();
//
}
@Bean
public IntegrationFlow uncompressionfileFlow() {
UnZipTransformer unZipTransformer = new UnZipTransformer();
IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(INBOUND_CHANNEL).transform(unZipTransformer)
.split(new UnZipAbstractMessageSplitter(prop1, prop2))
.log(Level.INFO, m -> "OUTBOUND: " + m.getPayload() + " HEADERS: " + m.getHeaders())
.enrichHeaders(h -> h.headerExpression(FileHeaders.ORIGINAL_FILE,
"payload.headers['" + FileHeaders.FILENAME + "']"));
return flowBuilder.channel(OUTBOUND_CHANNEL).get();
}
What you describe is fully related to round-robin dispatching strategy on the DirectChannel
: https://docs.spring.io/spring-integration/docs/current/reference/html/core.html#channel-implementations-directchannel. And according your config we indeed have two subscribers to the same INBOUND_CHANNEL
:
channel(INBOUND_CHANNEL).handle(new MessageHandler())
.from(INBOUND_CHANNEL).transform(unZipTransformer)
I'm not sure what is your goal, but logic in that code snippet is much complicated than just poll files from SFTP and process them.
You should revise what you have so far, but that's not an SFTP Inbound Channel Adapter problem, but more like two competing consumers on the same direct channel.