首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

ESB之旅(您说你干的比驴多、骡子就笑了——分析示例BookStore + Echo)

2012-10-10 
ESB之旅(你说你干的比驴多、骡子就笑了——分析示例BookStore + Echo))? 随后我把注意力转向了其他esb:Mule.?

ESB之旅(你说你干的比驴多、骡子就笑了——分析示例BookStore + Echo)

? 随后我把注意力转向了其他esb:Mule.? 这正是我想要的、文档很好、我能在10分钟内用eclipse跑起示例程序,细读了示例程序和指导书之后,花了4个小时就完成了我的第一个自定义测试,甚至还能更快。

? Mule也有提供IDE,可用于帮助创建新的服务,甚至可以在eclipse中运行 — 这意味着调试简化了很多。

?

? 按照江南白衣的归纳是:纷纷扰扰后,只剩下有实力的四国 :

, “融合”了数款Apache项目:ServiceMix、Camel、ActiveMQ等,由IONA公司(被Progress收购)提供支持,ServiceMix 4.0 重点已从JBI移到OSGI,而且IONA同时也是ActiveMQ与CXF背后的公司,三者整合良好。同时IONA还拥有corba产品orbacus,Progress拥有商业ESB产品Sonic ESB。Mule ?,最早声势最大的开源ESB,由MuleSource(Symphony出身、现在叫muleSoft)公司提供支持。缺点是Transport质量较差,缺乏强力的AS底层,缺少服务中介能力,服务编排方式不理想。 , JBoss提供支持,中规中矩没什么明显缺点的ESB...JBI (Java Business Integration)Java业务集成也就是jsr208规范。前者层次高一些,到了仅次于SOA的层次,所以叫SOA 落地 规范(IBM的中国买办们真能捅词啊);后者领域限定java,层次也低那么一点点,可以说就是个ESB实现的标准... ,我等不想接入标准之争,只想安安稳稳做项目,这些风险必须规避。SCA的开源实现目前最拉风的是现在SCA占上风。SCA规范很繁琐庞大,国内唯一的osoa成员普元承担了SCA规范的文档汉化工作,但就是汉化的文档说实话我也不愿意看,

? 实际上目前根本就不用关心SCA、JBI 这些规范标准,关心也没用,知道有这么个事就行了,it领域忽悠太多,演戏的不一定是疯子、看戏的不一定是傻子...??

? alloyer对mule的users guide翻译:https://groups.google.com/group/cgsoa-translate/files?hl=en

? 一篇关于JBI是什么的译文:

? What is Java Business Integration (JBI) or JSR 208

? 在javaOne大会上有大量关于JBI的报道和关注,在我们即将发布我们的开源JBI容器及组件套装ServiceMix 第一版之前这尤其是个好消息。 我估计大家还没有深入体验过JBI, 在JavaOne大会的JBI讨论上一些人脸上仍有困惑,所以我写下这篇文章做个科普,阐述一下JBI的价值所在以及如何使用它。

? 概括地说JBI就是一个 Normalized Message Service and Router 规格化消息服务和路由的简单API、以及部署一些集成服务的组件和管理模型,这些集成服务包括:routing engines路由引擎, BPEL引擎, rule systems规则系统, transformation engines转换引擎等等...

? JBI提供了一个逻辑XML消息网络,这个网络可以很好地映射到HTTP, email and JMS/MOM,这样它可以很好的适应遗留系统、二进制传输和RPC系统比如EJB、CORBA。 可以把JBI看作是在JMS之上的逻辑抽象,而且它还能支持不同的消息交换如:one way单程、 request response请求响应等等....

? BC(binding components )绑定组件处理所有的plumbing消息流和协议相关,SE(service engine components )服务引擎组件在逻辑 XML层上工作,做基于内容的路由、编排、规则、转换以及客户自定义enrichment?等等...
? 这样BPEL引擎不再需要去处理协议,传输和格式,它只是委托给JBI去做service endpoints服务端点的物理路由、基于内容的路由,规则引擎、转换引擎也可以基于JBI总线去工作。所以我认为JBI是集成组件开发者可以使用的很棒的API。

?? 现在大多数的应用开发人员都在写POJO服务、暴露为webservice然后扔到容器中,所以他们不需要直接使用JBI APIs。但向我们这样直接去做集成的人,JBI在ESB级别上提供了一种中间件、集成供应商以及OSS项目的方式。

? 相关评论:

? ? ? ? <service name="EchoUMO"> <component name="code"><model name="echoSample"> <service name="EchoUMO"> <inbound> <stdio:inbound-endpoint system="IN"/> <vm:inbound-endpoint path="echo"/> </inbound> <echo-component/> <outbound> <pass-through-router> <stdio:outbound-endpoint system="OUT"/> </pass-through-router> </outbound> </service></model>

<stdio:connector name="SystemStreamConnector" promptMessage="Please enter something: " messageDelayTime="1000"/>

<service name="EchoUMO"> <inbound> <axis:inbound-endpoint address="http://localhost:65081/services"> <soap:http-to-soap-request-transformer/> </axis:inbound-endpoint> <axis:inbound-endpoint address="http://localhost:65082/services"/> <vm:inbound-endpoint path="echo"/> </inbound> <echo-component/> ...</service>

<wsdl:definitions targetNamespace="http://simple.component.api.mule.org"><!--WSDL created by Apache Axis version: 1.4Built on Apr 22, 2006 (06:55:48 PDT)--><wsdl:message name="logResponse"> </wsdl:message><wsdl:message name="echoRequest"><wsdl:part name="in0" type="xsd:string"> </wsdl:part></wsdl:message><wsdl:message name="logRequest"><wsdl:part name="in0" type="xsd:string"> </wsdl:part></wsdl:message><wsdl:message name="echoResponse"><wsdl:part name="echoReturn" type="xsd:string"> </wsdl:part></wsdl:message><wsdl:portType name="$Proxy0"><wsdl:operation name="log" parameterOrder="in0"><wsdl:input message="impl:logRequest" name="logRequest"> </wsdl:input><wsdl:output message="impl:logResponse" name="logResponse"> </wsdl:output></wsdl:operation><wsdl:operation name="echo" parameterOrder="in0"><wsdl:input message="impl:echoRequest" name="echoRequest"> </wsdl:input><wsdl:output message="impl:echoResponse" name="echoResponse"> </wsdl:output></wsdl:operation></wsdl:portType><wsdl:binding name="EchoUMOSoapBinding" type="impl:$Proxy0"><wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="log"><wsdlsoap:operation soapAction=""/><wsdl:input name="logRequest"><wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://simple.component.api.mule.org" use="encoded"/></wsdl:input><wsdl:output name="logResponse"><wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://simple.component.api.mule.org" use="encoded"/></wsdl:output></wsdl:operation><wsdl:operation name="echo"><wsdlsoap:operation soapAction=""/><wsdl:input name="echoRequest"><wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://simple.component.api.mule.org" use="encoded"/></wsdl:input><wsdl:output name="echoResponse"><wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://simple.component.api.mule.org" use="encoded"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="EchoUMO"><wsdl:port binding="impl:EchoUMOSoapBinding" name="EchoUMO"><wsdlsoap:address location="http://localhost:65082/services/EchoUMO"/></wsdl:port></wsdl:service></wsdl:definitions>

<soapenv:Envelope> <soapenv:Body> <echoResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <echoReturn xsi:type="xsd:string">hello mule!</echoReturn> </echoResponse> </soapenv:Body></soapenv:Envelope>

<soapenv:Envelope> <soapenv:Body> <logResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </soapenv:Body></soapenv:Envelope

[10:52:27] INFO StdioMessageDispatcher [connector.stdio.0.dispatcher.16]: Connected: endpoint.outbound.stdio://system.outhello mule!

[10:52:10] INFO LogComponent [connector.http.0.receiver.16]: hello mule![10:52:10] INFO StdioMessageDispatcher [connector.stdio.0.dispatcher.15]: Connected: endpoint.outbound.stdio://system.out[Ljava.lang.Object;@15b4ad2

<wsdl:message name="echoResponse"> <wsdl:part name="echoReturn" type="xsd:int"></wsdl:part></wsdl:message>

<soapenv:Envelope> <soapenv:Body> <echoResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <echoReturn href="#id0"/> </echoResponse> <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int">123</multiRef> </soapenv:Body></soapenv:Envelope>

<soapenv:Envelope> <soapenv:Body> <soapenv:Fault> <faultcode>soapenv:Server.userException</faultcode> <faultstring> java.lang.NumberFormatException: For input string: "hello" </faultstring> <detail> <faultData xsi:type="ns1:NumberFormatException"/> <ns2:stackTrace>java.lang.NumberFormatException: For input string: "hello"at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)at java.lang.Integer.parseInt(Integer.java:447)at ......

if (muleContext !=null && !muleContext.isDisposed() && !muleContext.isDisposing()) { muleContext.dispose(); }

MuleContext context = new DefaultMuleContextFactory().createMuleContext( new SpringXmlConfigurationBuilder("foo-config.xml"));context.start();

另一个配置构造器实现是ScriptConfigurationBuilder,用法同上。

? 至于为什么xml后缀的配置文件就交给SpringXmlConfigurationBuilder、groovy后缀的就交给ScriptConfigurationBuilder...请参考mule源码根目录当中的configuration-builders.properties配置文件,该文件配置了什么后缀类型的配置资源 文件用什么类型的配置构造器 来处理。

? 在about Configration Builders 或mule的users-guide手册的home\Configuration Overview\Configuration Builders中提到mule提供两个标准配置构造器:

??? 1、SpringXmlConfigurationBuilder,默认配置构造器,它使用spring2.0配置,可以使用mule私有xml命名空间

??? 2、ScriptConfigurationBuilder,允许使用符合jsr-223的脚本引擎(Groovy、Jython)来配置mule。

? 除此以外你也可以使用你自己的自定义的配置构造器Custom Configuration Builders,只要你实现ConfigrationBuilder接口即可。它含有方法configure。大多情况下你可以继承AbstractResourceConfigurationBuilder也就是资源配置构造器抽象类,它将你在命令行输入的配置文件存储为实例变量:configResources也就是上述的配置资源

? 你的程序可以随时获取配置信息:

? MuleContext context = MuleServer.getMuleContext();
? MuleConfiguration configuration = context.getConfiguration();

?

? SpringXmlConfigurationBuilder除了把你输入的echo-config.xml作为配置外,还会自动包含进源码根目录下的default-mule-config.xml作为配置。最后剩下的工作就是处理Registry相关的了:

? registry = new SpringRegistry(applicationContext);——构建spring注册器
? muleContext.addRegistry(1, registry);——向mule上下文添加spring注册器
? registry.initialise();——spring注册器的初始化

? 关于注册器及其他,在后面的例子中再看。

热点排行