Apache Camel ftp 消费者一次又一次地加载相同的文件 [英] Apache Camel ftp consumer loads the same files again and again

查看:54
本文介绍了Apache Camel ftp 消费者一次又一次地加载相同的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下弹簧配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://camel.apache.org/schema/spring 
       http://camel.apache.org/schema/spring/camel-spring.xsd">

    <bean id="downloadLogger" class="com.thomsonreuters.oa.sdi.camel.DownloadLogger" />

    <bean id="fileFilter" class="com.thomsonreuters.oa.sdi.camel.IgnoreReadyFilesFilter" />

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="ftp://url_to_ftp?password=*******&amp;noop=true&amp;stepwise=false&amp;binary=true&amp;consumer.delay=10s&amp;recursive=true&amp;filter=#fileFilter" />
            <process ref="downloadLogger" />
            <to uri="file:data/outbox" />
        </route>
    </camelContext>

</beans>

在 ftp 端,我有 3 个文件夹,里面有我想要下载的文件.我想实现以下场景:

At the ftp side I have 3 folders with files which I want to download. I want to achieve following scenario:

  1. 在 ftp 上是固定数量的文件(例如 5),消费者在第一次数据拉取时将这些文件加载​​到目标文件夹
  2. 在第二次尝试加载文件时,ftp 状态仍然相同(5 个文件)并且骆驼 ftp 使用者什么都不做(除了检查新文件)
  3. 到 ftp 到达新的 2 个文件,并且在此数据拉取时消费者仅下载这两个新文件

目前我当前的解决方案每次运行数据加载过程时都会下载所有文件,我如何管理有关下载文件的信息以防止重复下载(我的意思是已经从 ftp 复制文件),我可以编写自己的过滤器将过滤掉已经下载的文件,但我相信应该有内置功能可以让我控制这个(也许idempotentRepository,实际上我不确定)...

At the moment my current solutions downloads all files each time when I run dataload process, how I can manage information about downloaded files to prevent downloads of duplicates (I mean already copied files from ftp), I can write my own filter which will filter out already downloaded files but I belive there should be built in feature which will give me controle of this (maybe idempotentRepository, actually I am not sure)...

推荐答案

如果您希望 Camel 在重新启动之间能够记住它之前下载的文件,您需要使用持久的幂等存储库.

You need to use a persistent idempotent repository if you want Camel to be able to remember which files it previously have downloaded, between restarts.

您需要在 ftp 端点上设置此选项:idempotentRepository

You need to set this option on the ftp endpoint: idempotentRepository

在此处查看更多详细信息:http://camel.apache.org/file2(注意:FTP 组件继承文件组件的选项.)

See more details here: http://camel.apache.org/file2 (Note: The FTP component inherits the options from the file component.)

维基页面上有一些如何使用不同商店的示例.您还可以建立自己的自定义商店.

There are some examples on the wiki page how to use different stores. And you can also build you custom store.

这篇关于Apache Camel ftp 消费者一次又一次地加载相同的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆