简体   繁体   English

Apache Camel文件格式

[英]Apache Camel File Formats

I am working on a project that automatically uploads files to the SFTP server. 我正在一个自动将文件上传到SFTP服务器的项目。 My project is now in production and functioning as per the initial requirement spec. 我的项目现在已经投入生产并按照初始需求规范运行。 My project picks-up a txt file from a predefined location. 我的项目从预定义的位置获取txt文件。 Now because of the size limit on the SFTP server, the txt file must now be Zipped before the upload. 现在,由于SFTP服务器的大小限制,现在必须在上传之前压缩txt文件。

I now want to change my camel route to cater not only for txt files but also for xls, csv and Zip files. 我现在想更改骆驼路线,不仅要满足txt文件的要求,还应满足xls,csv和Zip文件的要求。

How do i do that? 我怎么做?

Currently my route looks as follows: 目前,我的路线如下所示:

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 TIA

I don't see why you use such a complicated way of copying files. 我不明白为什么您要使用如此复杂的文件复制方式。 If I'm not mistaken you could just use this: 如果我没记错的话,您可以使用以下命令:

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")

This will pickup any file in the pickupLocation directory and the FTP compenent will write the file with the same name to the remote server. 这将拾取PickupLocation目录中的任何文件,FTP组件会将具有相同名称的文件写入远程服务器。

You can use the 'include' parameter of the File component to set a regex to match only certain file types: http://camel.apache.org/file2.html 您可以使用File组件的'include'参数来设置正则表达式以仅匹配某些文件类型: http : //camel.apache.org/file2.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM