mule in action翻译18 : 3.6 使用FTP传输
如果你曾涉足过因特网,你一定记得曾经FTP是多么的盛行。在HTTP和SSH之前,FTP是计算机间传输文件的主要方式。虽然近年来由于HTTP、SCP、BitTorrent的升起,FTP日渐衰落,但你还是可能会偶尔遇到一些应用需要使用FTP。
本节,学习使用FTP传输发送和接受数据。首先看如何轮询一个远程的FTP目录。如何看如何通过outbound endpoint向远程FTP站点发送数据。
配置FTP传输和配置FTP client是相似的。见表3.6
3.6.1 使用 inbound FTP endpoint 接收文件
某些商户只以支持FTP的集成机制发送销售数据给Prancing Donkey公司。为了接收这些数据,Prancing Donkey.使用mule去轮询远程的FTP服务器,并把取得的数据保存到文件系统,以便进行后续的手工处理。下面列表展示了,他们是如何实现的。(图3.16)
Listing 3.20 Polling a remote FTP directory every hour for new files
<flow name="retrieveSalesStatistics"> <!--注释1 配置ftp inbound endpoint--> <ftp:inbound-endpoint user="joe" password="123456" host="${ftp.host}" port="${ftp.port}" path="/ftp/incoming" pollingFrequency="3600000"/> <!--保存传输文件到 ./data/sales/statistics--> <file:outbound-endpoint path="./data/sales/statistics"/> </flow>
注释1处 配置inbound endpoint 。你指定了用户、密码、主机、端口、路径和对远程服务器的轮询频率。
FTP传输每隔一个小时将建立连接并传输新文件到注释2定义的outbound endpoint 。这个outbound endpoint将把文件写到 ./data/sales/statistics 目录.
最佳实践 FTP传输要和FTP inbound endpoint一起联合使用。通过一个flow来流化FTP数据时,如果文件 很大可能会有问题。比如一些FTP服务器有超时限制,当你正在现在文件进行的处理时可能会出现超时 问题。一个更好的选择是发送FTP文件到一个文件outbound endpoint,并在这里执行处理。
3.6.2 使用outbound FTP endpoint发送数据。
有时你需要发送文件到远程的FTP服务器。上例中的销售商要求 Prancing Donkey 周期性的使用FTP方式发送他们产品目录。为了实现这个功能,Prancing Donkey设置了一个存放文件的共享目录,mule会周期性的轮询并发送文件。如下列表所示(见表3.17)
Listing 3.21 Sending a file to a remote FTP server
<flow name="ftpProductCatalog"> <!--注释1 轮询该目录的文件--> <file:inbound-endpoint path="./data/in"/> <!--发送文件到 ftp服务器--> <ftp:outbound-endpoint user="joe" password="123456" host="${ftp.host}" port="${ftp.port}" path="/data/prancingdonkey/catalog"/> </flow>
注释1处 配置inbound endpoint 。文件将被放置到 ./data/in目录,然后将被传送给
注释2处的 FTP outbound endpoint。 这个ftp outbound endpoint将把文件放到FTP服务器的 /data/prancingdonkey/catalog 目录。
相关推荐
Mule in Action, Second Edition is a totally-revised guide covering Mule 3 fundamentals and best practices. It starts with a quick ESB overview and then dives into rich examples covering core concepts ...
mule in action 和doc文档详细介绍 Mule的核心组件是UMO(Universal Message Objects,从Mule2.0开始UMO这一概念已经被组件Componse所代替),UMO实现整合逻辑。UMO可以是POJO,JavaBean等等。它支持30多种传输协议...
Mule in Action, Second Edition 原版
Mule in Action is acomprehensive tutorial designed for working Java developers. This authoritativebook explores the architecture and the main features of version Mule 2 throughnumerous running ...
极品推荐,相信In Action,相信mule。
mule in action ,mule入门教程,系统学习资料,英文版
Mule3.6 Expression Language By 火花
著名ESB开源框架Mule的介绍书籍,英文第二版正式版本
mule in aciton:mule 实战,主要是社区成熟,文档丰富。开源esb
NULL 博文链接:https://chembo.iteye.com/blog/1064226
Mule in action 第二版,预览章节,预计2014年1月出版。
MULE IN ACTION Mule是一个企业服务总线(ESB)消息框架.它的主要特性包括: 1.基于J2EE1.4的企业消息总线(ESB)和消息代理(broker). 2.可插入的连接性:比如Jms,jdbc,tcp,udp,multicast,http,servlet,smtp,pop3, file,...
先决条件必须在要使用此传输的主机上安装 Erlang R13B01 或更高版本。在使用 Erlang 传输之前必须在启动 Erlang 连接器之前运行。 如果你有一个 Erlang 应用程序已经在运行 Mule 的主机上运行, epmd将已经运行。 ...
企业服务总线ESB中用户数量大,文档丰富,社区成熟的一款开源ESB。
介绍如何使用Mule ESB的好教程,2014年出版的。
Mule技术开始手册英文版Mule技术开始手册英文版