`

mule & seda的学习之一

    博客分类:
  • SOA
阅读更多
mule:轻量级的ESB消息框架,可以和spring集成,支持seda架构。

seda:分段式事件驱动架构,可以在每个stage上施加不同的thread,来确保程序的最大吞吐量。

几个名词解释

Connectiors:支持不同协议的连接器,屏蔽有不同协议带来的复杂度

EndPoints Address:终端地址,类似于jms等消息机制

UMO:统一消息对象,在mule里面他们是一些POJO,负责解释消息,处理消息,然后再发送给下一个UMO,形成一个UMO处理链。

mule框架地址http://www.mulesoft.org/

下载下来并解压缩打开examples文件夹,里面有很多例子,最初级的例子是echo

D:\mule\mule-standalone-2.2.1\examples

1.运行echo项目,初次体验mule

执行echo.bat批处理文件,有三种选择,你可以在命令窗口下输入1,2或者3选择不同的模式1是基本模式,2是Axis模式,3是CXF模式

对应着D:\mule\mule-standalone-2.2.1\examples\echo\conf文件夹下的三个配置文件,根据你的选择加装不同的配置文件

2.自己动手写一个echo程序,代码如下

EchoService接口

package com.zxgllhh.testMule;

public interface EchoService {

public String echo(String echo);
}

EchoComponent实现类

package com.zxgllhh.testMule.impl;

import com.zxgllhh.testMule.EchoService;

public class EchoComponent implements EchoService {

public String echo(String echo) {
System.out.println("Echo Component start....");
return echo;
}

}

加装配置文件的主动类

package com.zxgllhh.run;

import org.mule.api.MuleContext;
import org.mule.api.context.MuleContextFactory;
import org.mule.config.spring.SpringXmlConfigurationBuilder;
import org.mule.context.DefaultMuleContextFactory;

public class EagleMuleMain {
public static void main(String[] args) throws Exception{
try {
String configFile = "com/zxgllhh/run/mule-config.xml";
String[] configFileArr = new String[] { configFile };
MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
MuleContext context = muleContextFactory
.createMuleContext(new SpringXmlConfigurationBuilder(
configFileArr));
context.start();
} catch (Exception t) {
t.printStackTrace();
}
}
}

mule-config.xml配置文件

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:soap="http://www.mulesource.org/schema/mule/soap/2.2"
xmlns:cxf="http://www.mulesource.org/schema/mule/cxf/2.2"
xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.2"
xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.2"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
http://www.mulesource.org/schema/mule/soap/2.2 http://www.mulesource.org/schema/mule/soap/2.2/mule-soap.xsd
http://www.mulesource.org/schema/mule/cxf/2.2 http://www.mulesource.org/schema/mule/cxf/2.2/mule-cxf.xsd
http://www.mulesource.org/schema/mule/stdio/2.2 http://www.mulesource.org/schema/mule/stdio/2.2/mule-stdio.xsd
http://www.mulesource.org/schema/mule/vm/2.2 http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd">
<description>
this is a description, to be expert or not to be is not a question.
</description>

<model name="firstMuleModel">
<service name="firstModelService">

<inbound>
<stdio:inbound-endpoint system="IN"/>
<vm:inbound-endpoint path="echo"/>
</inbound>

<component class="com.zxgllhh.testMule.impl.EchoComponent"></component>

<outbound>
<pass-through-router>
<stdio:outbound-endpoint system="OUT"/>
</pass-through-router>
</outbound>

</service>
</model>
</mule>

发布成webservice应用,有webservice驱动程序运行代码修改如下

接口

package com.zxgllhh.testMule;

import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;

@WebService
public interface EchoService {
//定义返回参数节点
@WebResult(name="responseResultByzxg")
//定义请求参数节点
public String echo(@WebParam(name="requestResultByzxg") String string);
}

实现类

package com.zxgllhh.testMule.impl;

import com.zxgllhh.testMule.EchoService;

public class EchoComponent implements EchoService {

public String echo(String echo) {
return "Hello ,"+echo;
}

}

配置文件

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:soap="http://www.mulesource.org/schema/mule/soap/2.2"
xmlns:cxf="http://www.mulesource.org/schema/mule/cxf/2.2"
xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.2"
xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.2"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
http://www.mulesource.org/schema/mule/soap/2.2 http://www.mulesource.org/schema/mule/soap/2.2/mule-soap.xsd
http://www.mulesource.org/schema/mule/cxf/2.2 http://www.mulesource.org/schema/mule/cxf/2.2/mule-cxf.xsd
http://www.mulesource.org/schema/mule/stdio/2.2 http://www.mulesource.org/schema/mule/stdio/2.2/mule-stdio.xsd
http://www.mulesource.org/schema/mule/vm/2.2 http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd">

<description>
this is a description, to be expert or not to be is not a question.

To invoke the EchoUMO hit the following URL -
http://localhost:65082/services/EchoServiceUMO/echo/requestResultByzxg/zxg

To view the WSDL for the EchoUMO service go to -
http://localhost:65082/services/EchoServiceUMO?wsdl
</description>

<!-- CXF下的mule配置 -->
<model name="echoSample">
<service name="EchoService">
<inbound>
<cxf:inbound-endpoint address="http://localhost:65082/services/EchoServiceUMO"
serviceClass="com.zxgllhh.testMule.EchoService"/>
</inbound>
<component class="com.zxgllhh.testMule.impl.EchoComponent"></component>
</service>
</model>

<!--
<model name="firstMuleModel">
<service name="firstModelService">
<inbound>
<stdio:inbound-endpoint system="IN"/>
<vm:inbound-endpoint path="echo"/>
</inbound>
<component class="com.zxgllhh.testMule.impl.EchoComponent"></component>
<outbound>
<pass-through-router>
<stdio:outbound-endpoint system="OUT"/>
</pass-through-router>
</outbound>
</service>
</model>
-->
</mule>

对配置文件的总结

mule--description

--model--service--inbound

--outbound

--component

分享到:
评论

相关推荐

    mule &amp;amp; seda 学习二.docx

    mule &amp;amp; seda 学习二.docx

    mule学习笔记(初学者)

    这是mule入门时的学习笔记,供大家参考。对于初学者安装来说非常有效。

    mule学习文档

    此学习文档为mule,主要用于对开源框架mule的学习。有助于提高开发效率

    Mule3.4入门学习

    描述如何通过Mule实现Webservice的发布、实现JMS消息通信、ftp、File应用、协议转换等

    mule 学习.zip

    包含http、cxf、vm、sap、activeMq、ftp、file、poll、Smtp、attachment、melExpression、Java、template节点的使用示例等。

    mule IDE (mule ESB)

    Mule ESB 是一个轻量级的基于java的企业服务总线和集成平台, 使得开发人员可以快速,简单的连接多个应用, 使得它们可以交换数据。 Mule ESB 容易集成现有异构系统,包括:JMS, Web Services, JDBC, HTTP, 等. ESB...

    mule学习资料java轻量级框架

    mule的介绍和案例..............................................

    Mule企业版、社区版功能比较

    1. 固化代码库:Mule 企业版拥有一个固化的代码库,它解决了当下所有已知的 bug,Mulesoft 对其持续进行支持。这是社区版所不具备的,针对已知的 bug,社区版的用户必须自行修改代码进行修复。 2. 后端 bug 自动修复...

    mule文档详解 mule

    Mule是一个企业服务总线(ESB)消息框架,而且Mule是一个轻量级且高度可扩展的ESB。

    mule -esb 源码

    mule -esb 源码

    mule整体概念学习

    本文档适合初学mule的童鞋们,文档里面的内容参照了, 以下链接 http://my.oschina.net/moon/blog/10701 大家可以先看一下。 我在这基础上整理成一个word文档了并加了一些内容。收你一积分完全划算。有兴趣的朋友看...

    Mule ESB开发一个小例子

    mule,mule esb,Mule,ESB

    应用集成开源框架MULE的源代码

    Mule 的核心是一个基于SEDA的服务容器,该容器管理被称为通用消息对象(Universal Message Objects /UMO)的服务对象,而这些对象都是POJO。所有UMO和其他应用之间的通信都是通过消息端点(message endpoint)来进行...

    mule in action 说明+文档介绍

    Mule的核心组件是UMO(Universal Message Objects,从Mule2.0开始UMO这一概念已经被组件Componse所代替),UMO实现整合逻辑。UMO可以是POJO,JavaBean等等。它支持30多种传输协议(file,FTP,UDP,TCP,email,HTTP,SOAP,JMS...

    mule in action 即mule实战源码

    企业服务总线ESB中用户数量大,文档丰富,社区成熟的一款开源ESB。

    MuleStudio用户手册.doc

    Mule是一个以Java为核心的轻量级的消息框架和整合平台,基于EIP(Enterprise Integeration Patterns,由Hohpe和Woolf编写的一本书)而实现的。Mule的核心组件是UMO(Universal Message Objects,从Mule2.0开始UMO这一...

Global site tag (gtag.js) - Google Analytics