首先到 http://mule.codehaus.org/ 网站下载mule解压安装到本地硬盘,例如E:\java\mule-1.3-rc2
其次我们在这个目录下创建一个目录testmule用于测试
然后我们在testmule下创建如下目录
src :存放源文件
classes:存放java class文件
conf:存放xml配置文件
bin:存放测试执行的批处理(*.bat)文件
1、通用环境的搭建
以为为监听程序服务的接口和实现
Test.java
package org.lyj.mule;
public interface Test {
public void echo(String name);
}
Service.java
package org.lyj.mule;
public class Service implements Test {
public void echo(String name) {
System.out.println("called="+name);
}
}
从mule的sample下的任意一个例子的conf里把 log4j.properties 复制到 testmule/conf下,其中的内容如下
#Mule default logging configuration
#Logs to stdout and file. the log file is called mule.log and is stored in the directory
#that the mule server is executed in
log4j.rootCategory=error, stdout, file
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-5p %d [%t] %c: %m%n
# Maintain alog file with a single file backup
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=mule.log
log4j.appender.file.MaxFileSize=10MB
# Keep one backup file
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%-5p %d [%t] %c: %m%n
#You can set custom log levels per package here
log4j.logger.org.apache=WARN
#Switch to info to see Test suite lifecycle info
log4j.logger.org.mule.tck=WARN
2、File Provider的实现
在conf下新建一个配置文件 test-file-config.xml,内容如下
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mule-configuration PUBLIC "-//SymphonySoft //DTD mule-configuration XML V1.0//EN"
"http://www.symphonysoft.com/dtds/mule/mule-configuration.dtd">
<mule-configuration id="file" version="1.0">
<description>
本测试由刘玉军完整测试,如果有问题请访问http://blog.csdn.net/lyj_china
</description>
<model name="test file">
<mule-descriptor name="Service1" implementation="org.lyj.mule.Service">
<inbound-router>
<endpoint address="file:///D:/temp/">
<properties>
<property name="pollingFrequency" value="30000"/>
<property name="moveToDirectory" value="/D:/done"/>
</properties>
</endpoint>
</inbound-router>
</mule-descriptor>
</model>
</mule-configuration>
意思就是每隔30秒把文件从 d:/temp下移动到d:/done目录下
在bin下面创建文件 testfile.bat,内容如下:
@echo off
REM There is no need to call this if you set the MULE_HOME in your environment properties
if "%MULE_HOME%" == "" SET MULE_HOME=..\..
REM Set your application specific classpath like this
SET CLASSPATH=%MULE_HOME%\testmule\conf;%MULE_HOME%\testmule\classes;
call %MULE_HOME%\bin\mule.bat -config ../conf/test-file-config.xml
SET MULE_MAIN=
SET CLASSPATH=
然后我们运行testfile.bat 启动,正常启动mule后,就可以定时把 temp目录下的文件复制到done下了。
并且在mule运行界面会打印出文件的内容,也就是说我们在mule里可以监控到整个文件流。
<!--EndFragment-->
分享到:
相关推荐
博文链接:https://hideto.iteye.com/blog/65607
博文链接:https://hideto.iteye.com/blog/65822
mule in aciton:mule 实战,主要是社区成熟,文档丰富。开源esb
企业服务总线ESB中用户数量大,文档丰富,社区成熟的一款开源ESB。
MULE用户指南3.3 官方原版
mule in action ,mule入门教程,系统学习资料,英文版
用户数最多 社区最活跃的开源框架 企业服务总线 虽然没有实现JBI但是却非常好用。
–ServiceMix架构–ServiceMix组件概览–ServiceMix实战–Demo–Mule的工作机理–Mule组件概览–Mule实战–Demo–削弱了部门间的协作–影响资源的整合Point-to-PointsolutionHub-and-...作为ASF的一员,它集成了包括...
浪曦JavaScript框架实战开发及应用 ExtJs 3.0 Oracle数据库,企业软件的基石 真实企业级CRM项目 另配套附送本项目其它高级部分,手把手教学视频在浪曦CRM教学中,比如: Mule Esb发布基于CXF,Axis的WebService,...
source enterprise integration frameworks like Mule, Camel, ServiceMix, and Spring Integration. My work, over time, drove me to designing and developing processes and BPM , and I started using j BPM ...
为实现在CANoe中开发刷新功能,读取刷新文件相对较为复杂...实战使用过程中,遇到了ASCII的S19,Hex格式。二进制的bin文件。以及组合格式的VBF格式。 分享读取这2种文件的方法。有不同格式的文件,修改起来也大同小异;