首页 文章

入站sftp通道适配器自定义过滤器不再接受同一文件

提问于
浏览
1

我有一个非常简单的自定义过滤器用于入站sftp通道适配器,我只是检查文件扩展名是否在接受列表中 . 如果是这样,它返回true并应允许处理该文件 .

发生的事情是第一次处理文件它工作正常 . 如果在我的sftp服务器中删除了相同的文件,它将进入过滤器并且它返回true表示文件被接受仍然不会将该消息放在下游队列中 . 这是我的示例配置看起来像

<int-sftp:inbound-channel-adapter id="sftpAdapter"
			channel="ftpChannel"
			session-factory="sftpSessionFactory"
			local-directory="c:\\temp"
			remote-directory="//test//inbound"
			remote-file-separator="/"
			auto-create-local-directory="true"
			delete-remote-files="true"

			filter="customfilter"
			preserve-timestamp="true"
			>
		
		<int:poller cron="0/5 * * * * *" max-messages-per-poll="1"/>
	</int-sftp:inbound-channel-adapter>

1 回答

  • 1

    那是因为 AbstractInboundFileSynchronizingMessageSource 中还有一个 FileListFilter

    private volatile FileListFilter<File> localFileListFilter = new AcceptOnceFileListFilter<File>();
    

    由于您使用 filter="customfilter" 保证了 duplicate 逻辑,因此您应该配置 local-filter

    <int-sftp:inbound-channel-adapter id="sftpAdapter"
                channel="ftpChannel"
                ....
                local-filter="acceptAllFileFilter"/>
    
    <bean id="acceptAllFileFilter" class="org.springframework.integration.file.filters.AcceptAllFileListFilter"/>
    

相关问题