转载请标明出处!~
最近想学习mule,打算从成功运行第一个例子开始。mule最新版本是mule-standalone-3.0.0,而网上很多安装入门的例子都是以前的版本,在配置xml时与以前版本不同,自己只好网上了解资料。
1.用Myeclipse 8.5在线安装插件mule:mule-standalone-3.0.0.zip版本。
更新链接:
http://dist.muleforge.org/mule-ide/updates/3.4/
2.下载下载Mule 3.0.0:
http://www.mulesoft.org/download-mule-esb-community-edition
并解压到某一工作目录如:D:\software\mule
3.添加骡子安装目录和选择默认的分布使用与骡子项目
Windows ->Preferences->mule->add->选择刚才解压的工作目录D:\software\mule,然后点击“OK”
4.结合网上有关例子:开发第一个Mule项目——Hello World
总体结构如:
5.创建接口
- packagecom.mule.demo;
- publicinterfaceHello{
- publicStringhello(Stringname);
- }
package com.mule.demo;
public interface Hello {
public String hello(String name);
}
5.创建实现类
- packagecom.mule.demo;
- publicclassHelloImplimplementsHello{
- @Override
- publicStringhello(Stringname){
- returnname;
- }
- }
package com.mule.demo;
public class HelloImpl implements Hello {
@Override
public String hello(String name) {
// TODO Auto-generated method stub
return name;
}
}
6.编写配置文件
在项目目录下创建conf文件夹,并创建文件:hello-config.xml。当然,你也可以从mule的例子中复制一个配置文件到此,mule 3.0与之前版本的配置不同,要做适当的修改。要想实现控制台输入信息,刚要配置链接stdio,红色部分。下面的本例子的配置:
- <?xmlversion="1.0"encoding="UTF-8"?>
- <mulexmlns="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:cxf="http://www.mulesoft.org/schema/mule/cxf"
- xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"
- xsi:schemaLocation="
- http:
- http:
- http:
- http:
- >
- <!--
- Thesystemstreamconnectorisusedtosendandreceiveinformationviathe
- System.inandSystem.out.Notethisconnectorisonlyreallyusefulfortesting
- purposes.
- promptMessage-iswhatiswrittentotheconsole
- messageDelayTime-isthetimeinmillisecondsbeforetheuserispromptedagain.
- Thesepropertiesaresetasbeanpropertiesontheconnector.
- -->
- <stdio:connectorname="SystemStreamConnector"
- promptMessage="Pleaseenteryoutname:"
- messageDelayTime="1000"/>
- <!--
- TheMulemodelinitialisesandmanagesyourUMOcomponents
- -->
- <modelname="HelloSample">
- <!--
- AMuleservicedefinesallthenecessaryinformationabouthowyourcomponentswill
- interactwiththeframework,othercomponentsinthesystemandexternalsources.
- PleaserefertotheConfigurationGuideforafulldescriptionofalltheparameters.
- -->
- <servicename="HelloUMO">
- <inbound>
- <stdio:inbound-endpointsystem="IN"/>
- </inbound>
- <componentclass="com.mule.demo.HelloImpl"/>
- <outbound>
- <pass-through-router>
- <stdio:outbound-endpointsystem="OUT"/>
- </pass-through-router>
- </outbound>
- </service>
- </model>
- </mule>
<?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:cxf="http://www.mulesoft.org/schema/mule/cxf"
xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.0/mule.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/3.0/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/3.0/mule-stdio.xsd"
>
<!--
The system stream connector is used to send and receive information via the
System.in and System.out. Note this connector is only really useful for testing
purposes.
promptMessage - is what is written to the console
messageDelayTime - is the time in milliseconds before the user is prompted again.
These properties are set as bean properties on the connector.
-->
<stdio:connector name="SystemStreamConnector"
promptMessage="Please enter yout name: "
messageDelayTime="1000"/>
<!--
The Mule model initialises and manages your UMO components
-->
<model name="HelloSample">
<!--
A Mule service defines all the necessary information about how your components will
interact with the framework, other components in the system and external sources.
Please refer to the Configuration Guide for a full description of all the parameters.
-->
<service name="HelloUMO">
<inbound>
<stdio:inbound-endpoint system="IN" />
</inbound>
<component class="com.mule.demo.HelloImpl"/>
<outbound>
<pass-through-router>
<stdio:outbound-endpoint system="OUT" />
</pass-through-router>
</outbound>
</service>
</model>
</mule>
7.运行例子测试
右击hello-config.xml->run_configurations,则可看到运行效果。
来源:http://pj72021.iteye.com/blog/804956
ps:查找stdio的链接时发现mule3的例子网站:http://code.google.com/p/muleinaction/source/browse/branches/mule-3/chapter04/collection-aggregator/conf/collection-aggregator-config.xml?spec=svn479&r=479
分享到:
相关推荐
mule esb 项目 例子 入门
mule入门文档 mule入门文档 mule入门文档mule入门文档
Mule ESB 项目在Linux中的部署与开发与应用案例
mule的强大不用多说。 Mule 入门、介绍及架构理解
描述如何通过Mule实现Webservice的发布、实现JMS消息通信、ftp、File应用、协议转换等
Mule ESB 是一个轻量级的基于java的企业服务总线和集成平台, 使得开发人员可以快速,简单的连接多个应用, 使得它们可以交换数据。 Mule ESB 容易集成现有异构系统,包括:JMS, Web Services, JDBC, HTTP, 等. ESB...
mule standalone server 3
mule esb 3 user guider: 社区成熟,文档丰富的开源esb mule用户手册
This book provides a tutorial on how to develop Mule ESB 3 applications. It covers the essentials, such as using the Mule IDE, writing a configuration file, routing messages, and testing your ...
本文档是一个mule开发简介文档,属于mule入门级别,有使用者请下载
Mule是一个企业服务总线(ESB)消息框架,而且Mule是一个轻量级且高度可扩展的ESB。
mule in action ,mule入门教程,系统学习资料,英文版
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 ...
在按照本文进行操作之前,假设您的系统已经具备以下前提: 已经安装了Sun公司的JDK1.4或JDK5.0版本,推荐使用JDK5.0。 正确设置了JAVA_HOME环境变量到JDK目录(注意不是JRE目录)。 确保%JAVA_HOME%\bin路径在系统...
NULL 博文链接:https://incan.iteye.com/blog/308428
EIP经典案例Load Broker————Mule ESB实践
mule in action 和doc文档详细介绍 Mule的核心组件是UMO(Universal Message Objects,从Mule2.0开始UMO这一概念已经被组件Componse所代替),UMO实现整合逻辑。...Mule 3版本以后集成OSGi,支持热部署。