我有一个sftp适配器,它可以从远程位置下载文件并进行转换。但是,它将跳过备用文件。i、 e如果sftp中的主机文件是1.zip、2.zip、3.zip,那么它只处理1.zip和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();
}
1条答案
按热度按时间zd287kbt1#
你所描述的是完全相关的循环调度策略上
DirectChannel
: https://docs.spring.io/spring-integration/docs/current/reference/html/core.html#channel-实现directchannel。而根据你的配置,我们确实有两个相同的用户INBOUND_CHANNEL
:channel(INBOUND_CHANNEL).handle(new MessageHandler())
.from(INBOUND_CHANNEL).transform(unZipTransformer)
我不确定您的目标是什么,但是代码片段中的逻辑比从sftp轮询文件并处理它们要复杂得多。您应该修改到目前为止的内容,但这不是sftp入站通道适配器问题,更像是同一直接通道上的两个竞争消费者。