从SFTP读取文件并使用mulesoft转储到本地文件夹

时间:2017-03-29 11:26:52

标签: mule mule-studio

有人可以向我提供mulesoft xml,其中流正在从SFTP位置读取文件并将其转储到本地目录。

我写了以下代码,但它不起作用: 子流:

    <sub-flow name="loadFtpFile">
    <logger message="Load FTP File: #[flowVars.fileName]" level="INFO" doc:name="Load FTP File"/>
    <logger message="#[payload]" level="DEBUG" doc:name="Log Payload"/>
</sub-flow>

流程是:

<flow name="readFTP">
     <logger message="Read FTP file" level="INFO" doc:name="Read FTP file"/>
    <set-variable variableName="sftpEndpoint" value="sftp://{someUser}:{password}@{host}:22/incoming/test" doc:name="Set SFTP Endpoint"/>
    <set-variable variableName="fileName" value="debug.log" doc:name="Set File Name"/>
    <flow-ref name="loadFtpFile" doc:name="loadFtpFile"/>
   <file:outbound-endpoint path="C:\Users\Vikas\home\product" responseTimeout="10000" doc:name="Templocation" />

1 个答案:

答案 0 :(得分:0)

这是official documentation的一个例子。

configuation:

<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp"
      xmlns:file="http://www.mulesoft.org/schema/mule/file"
      xmlns:spring="http://www.springframework.org/schema/beans"
      xsi:schemaLocation="
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
          http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd
          http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
          http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">

    <!-- This placeholder bean lets you import the properties from the sftp.properties file. -->
    <spring:bean id="property-placeholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <spring:property name="location" value="classpath:sftp.properties"/>
    </spring:bean>

    <flow name="sftp2file">
        <sftp:inbound-endpoint host="${sftp.host}" port="${sftp.port}" path="/home/test/sftp-files" user="${sftp.user}" password="${sftp.password}"> 
                    <file:filename-wildcard-filter pattern="*.txt,*.xml"/> 
                </sftp:inbound-endpoint>
        <file:outbound-endpoint path="/tmp/incoming" outputPattern="#[message.inboundProperties.originalFilename]"/> 
    </flow>
</mule>

这里是引用属性文件:

sftp.user=memyselfandi
sftp.host=localhost
sftp.port=8081
sftp.password=icannottellyou

尝试一下,随意提出更精确的排队。