【问题标题】:int-ftp:inbound-channel-adapter fetch in sequential order?int-ftp:inbound-channel-adapter 按顺序获取?
【发布时间】:2015-07-22 14:35:27
【问题描述】:

我怎样才能让 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 必须按顺序将文件提取到我的本地系统它们被创建(时间戳)。

请建议。

问候, 拉维

【问题讨论】:

    标签: spring spring-integration


    【解决方案1】:

    <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 将远程文件拉到本地目录之后,轮询器开始为消息流提取它们。

    【讨论】:

    • 感谢您的快速回复。我使用了 int-ftp:inbound-channel-adapter 没有比较器属性,它不是按照创建顺序来获取文件,我需要用日期逻辑实现比较器吗?我是新来的 SI。请提出建议。
    • 对,你应该实现 Comparator 来命令你的文件进行处理。
    猜你喜欢
    • 2017-08-29
    • 2016-05-24
    • 1970-01-01
    • 2016-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-02
    • 1970-01-01
    相关资源
    最近更新 更多