ITeye博客

mule & seda的学习之一

hamlzf · 2011-11-02 17:18 · SOA · 企业架构 · SOA · mule · seda · Markdown

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配置文件 this is a description, to be expert or not to be is not a question. 发布成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; } } 配置文件 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 对配置文件的总结 mule--description --model--service--inbound --outbound --component

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。