0
我想實現簡單的SFTP通道適配器來接受任何文件名(允許重複的文件名)的文件。對於第一次輪詢,文件從SFTP服務器目錄傳輸到本地目錄,訂閱此通道的服務激活器能夠接收該消息,但是如果我第二次在SFTP服務器中保留具有相同名稱的文件,文件被傳輸,但服務激活器無法獲取消息。我試圖實現本地過濾器,但它進入了無限循環(輪詢文件並創建消息)。春季集成SFTP通道適配器不發送消息到第二次輪詢的下游服務激活器
配置
<int:channel id="inboundMGetRecursive">
<int:queue/>
</int:channel>
<int-sftp:inbound-channel-adapter id="sftpInboundAdapter"
auto-startup="true"
channel="channel1"
session-factory="sftpSessionFactory"
local-directory="c:/tmp/"
remote-directory="${sftp.file.remote.inbound.dir}"
auto-create-local-directory="false"
filename-pattern="*.txt"
local-filter="acceptAll">
<int:poller fixed-delay="60000" error-channel="sftpExceptionsChannel"
max-messages-per-poll="-1"/>
<bean id="acceptAll" class="org.springframework.integration.file.filters.AcceptAllFileListFilter"/
<int:service-activator id="serviceActivator" input-channel="channel1" ref="fileMoverHandler"
method="method1">
<int:poller fixed-rate="3000" max-messages-per-poll="-1"/>
</int:service-activator>
無限循環日誌
2016-12-14 13:25:39,632 [task-scheduler-1] [handlers.FileFilter] INFO - Filter Activated
2016-12-14 13:25:39,635 [task-scheduler-1] [handlers.FileFilter] INFO - file name : config.txt
2016-12-14 13:25:39,636 [task-scheduler-1] [file.FileReadingMessageSource] DEBUG - Added to queue: [C:\tmp\csvfiles\staging\config.txt]
2016-12-14 13:25:39,636 [task-scheduler-1] [file.FileReadingMessageSource] INFO - Created message: [GenericMessage [payload=C:\tmp\csvfiles\staging\config.txt, headers={id=4a062556-4181-2806-d2ee-c0aa3221aec3, timestamp=1481743539636}]]
2016-12-14 13:25:39,636 [task-scheduler-1] [endpoint.SourcePollingChannelAdapter] DEBUG - Poll resulted in Message: GenericMessage [payload=C:\tmp\csvfiles\staging\config.txt, headers={id=4a062556-4181-2806-d2ee-c0aa3221aec3, timestamp=1481743539636}]
2016-12-14 13:25:39,636 [task-scheduler-1] [channel.QueueChannel] DEBUG - preSend on channel 'inboundMGetRecursive', message: GenericMessage [payload=C:\tmp\csvfiles\staging\config.txt, headers={id=4a062556-4181-2806-d2ee-c0aa3221aec3, timestamp=1481743539636}]
2016-12-14 13:25:39,636 [task-scheduler-1] [channel.QueueChannel] DEBUG - postSend (sent=true) on channel 'inboundMGetRecursive', message: GenericMessage [payload=C:\tmp\csvfiles\staging\config.txt, headers={id=4a062556-4181-2806-d2ee-c0aa3221aec3, timestamp=1481743539636}]
2016-12-14 13:25:39,637 [task-scheduler-1] [handlers.FileFilter] INFO - Filter Activated
2016-12-14 13:25:39,637 [task-scheduler-1] [handlers.FileFilter] INFO - file name : config.txt
2016-12-14 13:25:39,637 [task-scheduler-1] [file.FileReadingMessageSource] DEBUG - Added to queue: [C:\tmp\csvfiles\staging\config.txt]
2016-12-14 13:25:39,638 [task-scheduler-1] [file.FileReadingMessageSource] INFO - Created message: [GenericMessage [payload=C:\tmp\csvfiles\staging\config.txt, headers={id=a2df4814-f759-0440-8ce2-c8d969a9315d, timestamp=1481743539638}]]
2016-12-14 13:25:39,638 [task-scheduler-1] [endpoint.SourcePollingChannelAdapter] DEBUG - Poll resulted in Message: GenericMessage [payload=C:\tmp\csvfiles\staging\config.txt, headers={id=a2df4814-f759-0440-8ce2-c8d969a9315d, timestamp=1481743539638}]
2016-12-14 13:25:39,638 [task-scheduler-1] [channel.QueueChannel] DEBUG - preSend on channel 'inboundMGetRecursive', message: GenericMessage [payload=C:\tmp\csvfiles\staging\config.txt, headers={id=a2df4814-f759-0440-8ce2-c8d969a9315d, timestamp=1481743539638}]
2016-12-14 13:25:39,639 [task-scheduler-1] [channel.QueueChannel] DEBUG - postSend (sent=true) on channel 'inboundMGetRecursive', message: GenericMessage [payload=C:\tmp\csvfiles\staging\config.txt, headers={id=a2df4814-f759-0440-8ce2-c8d969a9315d, timestamp=1481743539638}]
2016-12-14 13:25:39,639 [task-scheduler-1] [handlers.FileFilter] INFO - Filter Activated
2016-12-14 13:25:39,639 [task-scheduler-1] [handlers.FileFilter] INFO - file name : config.txt
2016-12-14 13:25:39,640 [task-scheduler-1] [file.FileReadingMessageSource] DEBUG - Added to queue: [C:\tmp\csvfiles\staging\config.txt]
2016-12-14 13:25:39,640 [task-scheduler-1] [file.FileReadingMessageSource] INFO - Created message: [GenericMessage [payload=C:\tmp\csvfiles\staging\config.txt, headers={id=fd1ace38-6550-82ea-89c5-2a6229463167, timestamp=1481743539640}]]
2016-12-14 13:25:39,640 [task-scheduler-1] [endpoint.SourcePollingChannelAdapter] DEBUG - Poll resulted in Message: GenericMessage [payload=C:\tmp\csvfiles\staging\config.txt, headers={id=fd1ace38-6550-82ea-89c5-2a6229463167, timestamp=1481743539640}]
2016-12-14 13:25:39,640 [task-scheduler-1] [channel.QueueChannel] DEBUG - preSend on channel 'inboundMGetRecursive', message: GenericMessage [payload=C:\tmp\csvfiles\staging\config.txt, headers={id=fd1ace38-6550-82ea-89c5-2a6229463167, timestamp=1481743539640}]
2016-12-14 13:25:39,640 [task-scheduler-1] [channel.QueueChannel] DEBUG - postSend (sent=true) on channel 'inboundMGetRecursive', message: GenericMessage [payload=C:\tmp\csvfiles\staging\config.txt, headers={id=fd1ace38-6550-82ea-89c5-2a6229463167, timestamp=1481743539640}]
請幫助我如何使用過濾器來接受所有文件。
謝謝Gary的回覆。但它在一秒鐘內多次輪詢,儘管我有1分鐘的輪詢固定延遲。請糾正我,如果我失去了一些東西。 – Abhilash
請勿使用隊列通道;從通道中刪除' ',並從服務激活器中刪除輪詢器。它現在將在適配器的輪詢線程上運行。在適配器輪詢器的線程返回給輪詢器之前,必須刪除該文件。 –
我已經從通道中刪除隊列,也從服務激活器中刪除了輪詢,但仍然是第二次入站通道適配器在1秒內輪詢多次。當我只保留本地過濾器時發生這種情況。 – Abhilash