spring - int-ftp :inbound-channel-adapter fetch in sequential order?

标签 spring spring-integration

如何使 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/

相关文章:

java - 当有多个用户同时访问页面时,是否需要在我的controller方法中添加synchronization关键字?

java - @Transactional 回滚以及 @ExceptionHandler

java - 如何在不轮询的情况下保存一个消息队列并拥有一组工作线程?

java - 如何指定使用Spring Cloud Stream向RabbitMQ发送消息的超时?

spring - 在Swagger UI/Spring Boot中支持多个路径映射

java - 使用 Spring Security 当用户不存在时如何显示错误消息?

Spring Boot不等待请求

spring - 在 Spring 中以编程方式将 QueueChannel 桥接到 MessageChannel

spring-integration:如何以 SSE 形式提供延迟详细信息

java - 通过 Spring 集成使用队列中的消息