从SFTP读取文件并使用mulesoft转储到本地文件夹 [英] read file from SFTP and dump to local folder using mulesoft

查看:75
本文介绍了从SFTP读取文件并使用mulesoft转储到本地文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以给我提供一个mulesoft xml,其中的流程是从SFTP位置读取文件并将其转储到本地目录中.

Can someone provide me an mulesoft xml where the flow is reading files from SFTP location and dumping it to the local directory.

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

I have written following code but it does not work: subflow :

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

推荐答案

这是配置:

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

,这里是引用属性文件:

and here the references properties file:

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

尝试一下,随时询问更精确的问题.

try it out and feel free to ask more precise queation.

这篇关于从SFTP读取文件并使用mulesoft转储到本地文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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