I've defined a flow using spring-integration java dsl to ftp transfer a file, handle it, then transfer it back in an "archive" dir, and at last move it in a local archive dir.
Which is something "quite easy" as:
@Bean
public IntegrationFlow ftpInboundFlow() {
if (ftpProperties.getEnabled() == false) {
return null;
}
logger.trace("Starting ftp flow");
return IntegrationFlows
.from(source -> source.ftp(ftpSessionFactory()).deleteRemoteFiles(true).preserveTimestamp(true)
.filter(compositeWithAcceptOnceFilter()) .remoteDirectory(ftpProperties.getRemoteDirectory())
.localDirectory(new File(ftpProperties.getLocalDirectory())).autoCreateLocalDirectory(true),
consumer -> consumer.id("ftpInboundAdapter")) /* Fine from() */
.handle(new GenericHandler<File>() {
@Override
@Transactional
public Object handle(File payload, Map<String, Object> headers) {
logger.debug("Data arrived {} {}", payload, payload.getClass().getName());
return payload;
}
}) /* Fine GenericHandler */
.handleWithAdapter(a -> a.ftp(ftpSessionFactory())
.remoteDirectory(ftpProperties.getRemoteArchiveDirectory()).autoCreateDirectory(true))
.get();
}
If I append
.handleWithAdapter(a -> a.file("'" + ftpProperties.getLocalArchiveDirectory() + "'")
.autoCreateDirectory(true).deleteSourceFiles(true))
after the ftp adapter configuration the bean initializer replies with the following error message:
Caused by: org.springframework.beans.factory.BeanCreationException: The 'currentComponent' (org.springframework.integration.file.remote.handler.FileTransferringMessageHandler@80bfa9d) is a one-way 'MessageHandler' and it isn't appropriate to configure 'outputChannel'. This is the end of the integration flow.
How should I fix it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…