如何使 int-ftp:inbound-channel-adapter 按照文件在远程系统上创建的顺序获取文件?
例如:
File1 - 15:31:01
File2 - 15:32:02
File3 - 15:33:03
File4 - 15:34:04
File5 - 15:35:05
假设我的应用程序关闭了 5 分钟,此时创建了 5 个文件,一旦我重新启动/重新部署我的应用程序,int-ftp:inbound-channel-adapter 必须按顺序将文件获取到我的本地系统它们被创建(时间戳)。
请提出建议。
问候, 拉维
最佳答案
<int-ftp:inbound-channel-adapter>
有comparator
属性:
<xsd:attribute name="comparator" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specify a Comparator to be used when ordering Files. If none is provided, the
order will be determined by the java.io.File implementation of Comparable.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
用于内部queue
:
public FileReadingMessageSource(Comparator<File> receptionOrderComparator) {
this.toBeReceived = new PriorityBlockingQueue<File>(
DEFAULT_INTERNAL_QUEUE_CAPACITY, receptionOrderComparator);
}
FtpInboundFileSynchronizer
之后在轮询器开始拾取远程文件以进行消息流之前,将远程文件拉到本地目录。
关于spring - int-ftp :inbound-channel-adapter fetch in sequential order?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31566268/