【问题标题】:Mule ESB: moving remote CSV file to another directoryMule ESB:将远程 CSV 文件移动到另一个目录
【发布时间】:2017-01-28 04:24:57
【问题描述】:

我希望使用 Mule 将 CSV 文件从一个远程目录移动到服务器上的另一个目录以进行归档。例如,移动以下内容: /record/report.csv 到 /archive/reports/report_04_09_2015.csv。用骡子可以吗?只是澄清一点,目录不在本地服务器上,它们在不同的服务器上。这个过程至少需要 ftp

【问题讨论】:

  • 是的,有可能

标签: ftp mule


【解决方案1】:

您可以使用文件入站端点并配置 moveToPattern 和 moveToDir 属性。在下面的示例中,文件入站将从输入文件夹中读取文件并将其移动到 outputDir,名称模式指定为 moveToPattern。将文件转换为字符串以确保从输入目录中删除文件。

<flow name="MoveFile">
        <file:inbound-endpoint path="input" moveToPattern="#[message.inboundProperties.originalFilename + '_' + server.dateTime.format('dd_MM_yyyy')]" moveToDirectory="archiveDir" responseTimeout="10000" doc:name="File"/>
        <file:file-to-string-transformer doc:name="File to String"/>
        <logger message="File Moved" level="INFO" doc:name="Logger"/>
    </flow>

如果服务器不在网络中,也可以使用 FTP。配置 FTP 连接器以设置 moveTo 目录和模式 -

<ftp:connector name="FTP" pollingFrequency="1000" validateConnections="true" moveToDirectory="/archive/reports/" moveToPattern="#[message.inboundProperties.originalFilename + '_' + server.dateTime.format('dd_MM_yyyy')]" doc:name="FTP"/>
<flow name="testFlow24">
        <ftp:inbound-endpoint host="localhost" port="21" path="/record/" connector-ref="FTP" responseTimeout="10000" doc:name="FTP">
            <file:filename-regex-filter pattern="report.csv"/>
        </ftp:inbound-endpoint>
</flow>

【讨论】:

  • 您不能使用文件连接器连接到网络外的远程服务器
  • 没错,我已经更新了使用 FTP 显示的答案。
猜你喜欢
  • 2014-07-18
  • 2014-12-04
  • 1970-01-01
  • 2017-07-20
  • 2018-12-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-26
相关资源
最近更新 更多