我有以下初始弹簧集成流程:
final var inboundStreamingAdapter = Sftp.inboundStreamingAdapter(new SftpRemoteFileTemplate(sftpSessionFactory))
.patternFilter("*.csv")
.remoteDirectory(sftpRemoteDirectoryDownload);
IntegrationFlows.from(inboundStreamingAdapter,
c -> c.poller(Pollers.trigger(new PeriodicTrigger(10)).maxMessagesPerPoll(1)))
.channel("data")
.split(mySplitter)
.get();
并且我的sftp服务器上有以下文件:
.DS_Store
PL_12002_1815_1.csv1
据我所知,适配器应该过滤掉所有以csv后缀结尾的内容。
实际发生的情况是,某些文件(.DS_Store)有时会根据当前存储在FTP上的内容进入mySplitter。
据我所知问题出在AbstractRemoteFileStreamingMessageSource(用作SftpStreamingMessageSource类的基类)中:
if (this.filter != null && this.filter.supportsSingleFileFiltering()
&& !this.filter.accept(file.getFileInfo())) { //HERE APPLY A FILTER AND FIND OUT PL_12002_1815_1.csv1 SHOULD NOT BE PROCESSED
if (this.toBeReceived.size() > 0) { // don't re-fetch already filtered files
//HERE WE LOAD ANOTHER FILE FROM THE QUEUE (.DS_Store)
file = poll();
}
else {
file = null;
}
}
//FILTER IS NOT REAPPLIED FURTHER DOWN AND WE CREATE A MESSAGE FOR .DS_Store
if (file != null) {
try {
String remotePath = remotePath(file);
Session<?> session = this.remoteFileTemplate.getSession();
try {
return getMessageBuilderFactory()
.withPayload(session.readRaw(remotePath))
.setHeader(IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE, session)
.setHeader(FileHeaders.REMOTE_DIRECTORY, file.getRemoteDirectory())
.setHeader(FileHeaders.REMOTE_FILE, file.getFilename())
.setHeader(FileHeaders.REMOTE_HOST_PORT, session.getHostPort())
.setHeader(FileHeaders.REMOTE_FILE_INFO,
this.fileInfoJson ? file.toJson() : file);
}
我会说这是一个错误,但是也许我只是配置错误,有人可以帮忙吗?