读书人

Mule3.4.0 ftp的运用将通过ftp文件迁移

发布时间: 2013-09-04 10:34:09 作者: rapoo

Mule3.4.0 ftp的应用将通过ftp文件迁移
<?xml version="1.0" encoding="UTF-8"?><mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp" xmlns:file="http://www.mulesoft.org/schema/mule/file" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/current/mule-ftp.xsd"><!--连接 FTP 服务器的连接器从 ftp 服务器从一个目录迁移到另外一个目录的方法 --> <file:connector name="fileConnector" streaming="false" pollingFrequency="1000" autoDelete="true"> <file:expression-filename-parser /> </file:connector> <model name="fileMode"> <service name="fileService"> <inbound> <file:inbound-endpoint path="/E:/download"> <!--过滤条件可以有选择的读取文件,下面的方式只拷贝后缀名为txt的文件到archive目录中,当然还可以使用其他的方式 <file:filename-wildcard-filter pattern="*.txt" />--> </file:inbound-endpoint> </inbound> <outbound> <pass-through-router><!-- 如果没有#[header:originalFilename]那么原始文件的文件名和后缀就会使文件名被随机的生成后缀名是.bat --> <file:outbound-endpoint path="/E:/upload" outputPattern="#[header:originalFilename]" > </file:outbound-endpoint> </pass-through-router> </outbound> </service> </model></mule>

?

测试代码:

import org.mule.api.MuleContext;import org.mule.api.MuleException;import org.mule.api.context.MuleContextFactory;import org.mule.config.spring.SpringXmlConfigurationBuilder;import org.mule.context.DefaultMuleContextFactory;/** * <p>通过ftp将同一个服务器上的文件从一个目录迁移到另外一个目录<p> * * 创建日期 2013-8-17<br> * @author  $Author$<br> * @version $Revision$ $Date$ * @since   3.0.0 */public class MuleClientMain {    public static void main(String[] args) {        try {            String configFile = "mule-file-move-config.xml";            String[] configFileArr = new String[] {configFile };            MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();            MuleContext context = muleContextFactory                    .createMuleContext(new SpringXmlConfigurationBuilder(configFileArr));            context.start();        } catch (MuleException t) {            t.printStackTrace();        }    }}

?

读书人网 >软件架构设计

热点推荐