【问题标题】:Mule: How to pass File from FTP to Java class in Mule ESB?Mule:如何将文件从 FTP 传递到 Mule ESB 中的 Java 类?
【发布时间】:2013-12-23 15:25:10
【问题描述】:

在 Mule 中,我从 FTP 服务器下载文件。我想将此目录中的所有文件传递给我的 java 类,该类应该在我的流程中的 Download_ZIP_File 之后执行操作。我需要执行读取文本文件和使用 Java 解压缩压缩文件等操作。

我的流程中应该有一个Java类,下载完成后应该对其进行函数调用。这个类的对象必须知道有关下载文件的所有信息。

有人可以帮忙吗?这是我目前的流程;

我的这个流程的 XML 是这样的;

 <?xml version="1.0" encoding="UTF-8"?>

 <mule xmlns:ftp="http://www.mulesoft.org/schema/mule/ee/ftp"
        xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" 
        ... >
    <file:endpoint name="Download_File_KBB" responseTimeout="10000" doc:name="File" path="E:\csv\output"/>
    <file:connector name="Global_File_Connector" autoDelete="false" streaming="false" validateConnections="true" doc:name="File"/>
    <flow name="ftp_kbb_download_fileFlow1" doc:name="ftp_kbb_download_fileFlow1">
       <ftp:inbound-endpoint host="${ftp.host}" port="${ftp.port}" path="${ftp.pathInbound}" user="${ftp.user}" password="${ftp.password}" responseTimeout="10000" doc:name="KBB_FTP">
       </ftp:inbound-endpoint>
       <logger message="KBBUsedVehiclesNoSpecTabFormat-#[server.dateTime.year]-W#[server.dateTime.weekOfYear]" level="INFO" doc:name="Logger"/>
       <file:outbound-endpoint path="${file.inboundEndpoint}" outputPattern="#[header:originalFilename]" responseTimeout="10000" doc:name="Donwload_ZIP_FILE" connector-ref="Global_File_Connector"/>
    </flow>
  </mule>

【问题讨论】:

    标签: mule mule-studio mule-el mule-module-jpa


    【解决方案1】:

    一种选择是创建一个实现org.mule.api.lifecycle.Callable 的类,然后在您的配置中使用component 元素对其进行配置。

    然后,您将可以完全访问此 Callable 类的 onCall 方法中的 MuleEventContext

    【讨论】:

    • 谢谢大卫,我快到了。请告诉我如何将 mule-app.properties 中的属性传递给这个 java 组件的 MuleEventContext 消息。问题是我在 MuleEventContext 和文件名中获得了 FTP 服务器的端点。但是我没有得到保存本地计算机上文件的 file.inboundEndpoint 位置。我需要知道这个属性来处理下载的文件...
    • 使用 Spring 在你的组件中注入这些属性。
    • 我正在工作.. 引用了 mulesoft.org/documentation/display/current/… 的对象工厂 ...我们需要在实现 Callable 的示例类中简单地创建 Setter 函数
    • 大卫,你能回答这个问题吗? stackoverflow.com/questions/20704818/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多