Mule:如何将文件从FTP传递到Mule ESB中的Java类? [英] Mule: How to pass File from FTP to Java class in Mule ESB?

查看:98
本文介绍了Mule:如何将文件从FTP传递到Mule ESB中的Java类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In Mule, I am downloading files from FTP server. I want to pass all the files in this directory to my java class which should be performing actions after Download_ZIP_File in my flow. I need to perform actions like reading text files and unzip the zipped files using Java.

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

There should be a Java class in my flow, for which a function call should be raised when download is complete.. Object of this class must know all the information about downloaded files.

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

Can someone please help on this.? Here is my current flow;

我对此流程的XML是这样的;

My XML for this flow is like this;

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

推荐答案

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

One option is to create a class that implements org.mule.api.lifecycle.Callable then configure it with a component element in your config.

然后,您将具有此Callable类的onCall方法中的MuleEventContext的完全访问权限.

Then, you will have full access to the MuleEventContext in the onCall method of this Callable class.

这篇关于Mule:如何将文件从FTP传递到Mule ESB中的Java类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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