Apache Camel文件格式

时间:2014-10-09 09:18:09

标签: java apache-camel

我正在开发一个自动将文件上传到SFTP服务器的项目。我的项目现在已按照初始要求规范进行生产和运行。我的项目从预定义的位置获取txt文件。现在由于SFTP服务器的大小限制,现在必须在上传之前将txt文件压缩。

我现在想改变我的骆驼路线,不仅适用于txt文件,还适用于xls,csv和Zip文件。

我该怎么做?

目前我的路线如下:

from("quartz://myscheduler?cron={{cron}}")
.pollEnrich("file:{{pickuplocation}}?moveFailed=error/${file:name.noext}_${date:now:yyyyMMddHHmmssSSS}.${file:ext}&move=SFTPCompleted/${date:now:MMM}-${date:now:yyyy}/${file:name.noext}_${date:now:yyyyMMddHHmmssSSS}.${file:ext}") 
        .setHeader("CamelFileName", simple("${file:name}"))
        .setHeader("RouteID",constant("Route ID"))          
        .multicast()
            .to("sftp://"+username+"@"+SftpLocation+"password="+password+"&stepwise=false&disconnect=true&fileName=${file:name.noext}.txt")
        .end()

TIA

1 个答案:

答案 0 :(得分:2)

我不明白为什么你使用如此复杂的方式复制文件。如果我没弄错的话你可以用它:

from("file:{{pickuplocation}}?moveFailed=error/${file:name.noext}_${date:now:yyyyMMddHHmmssSSS}.${file:ext}&move=SFTPCompleted/${date:now:MMM}-${date:now:yyyy}/${file:name.noext}_${date:now:yyyyMMddHHmmssSSS}.${file:ext})
.to("sftp://"+username+"@"+SftpLocation+"password="+password+"&stepwise=false&disconnect=true")

这将拾取pickupLocation目录中的任何文件,FTP部门将把具有相同名称的文件写入远程服务器。

您可以使用“文件”组件的“include”参数将正则表达式设置为仅匹配特定文件类型:http://camel.apache.org/file2.html

相关问题