一个基于Mule的企业服务总线的案例

<iframe align="center" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog.html" frameborder="0" width="728" scrolling="no" height="90"></iframe>

原文地址: http://www.theserverside.com/tt/articles/article.tss?l=CaseStudyMule

面向服务架构的关键字之一就是ESB。以前很多厂商靠买消息服务器来提供集成交互的方案,然后出现了SOAP和REST。

早期的尝试基本上都是通过定一个固定的消息格式,例如xml来让各个系统交换。但是这些消息格式本身经常需要修订,就给集成带来了很大的麻烦。

最好的解决方案就是每个应用还是用自己支持的接口,例如EDI或者SOAP,然后构建一个可以集成各种结构的聚合器,每一个应用的接口就开发成聚合器的一个端口。这样一个cobol写的应用就可以和一个j2me的应用交互,而不需要知道彼此的技术细节。

常见ESB供应商比较

Product

Vendor

Connects with...

Matrix BusinessWorks

TIBCO

SOAP, EMS, JMS, Rendezvous, MQ, BPEL

Mule ESB

Open-source, MuleSource, Inc.

SOAP, REST, JMS, MQ, JBI, AQ, Caching, JavaSpaces, GigaSpaces, Email, IM, JCA, AS400 Data Queues, System I/O.

OpenESB

Open-source, Sun Microsystems

JBI, JCA, JAX-RPC, JAX-WS

Sonic ESB

Progress Software

JMS, SOAP, JMX

Websphere ESB

IBM

JMS, MQ, SOAP; requires additional adapters to interface with other products and legacy protocols; requires Websphere to work

这里少了一个ServiceMix。

下面是这个案例的细节:

本案例用到的程序包括:

  • AMD-based 2.6 GHz 4 GB RAM, and Intel-based 3 GHz 4 GB RAM servers
  • Solaris 10 and Ubuntu Linux Dapper Drake
  • Java Run-time Environment 1.5.9
  • Mule current general availability package
  • A commercial JMS provider
  • Commercial applications for order capture, inventory management, order management, fulfillment, and reporting
  • 假设有一个项目要集成很多企业级应用程序,出于开发周期的压力,我们选择集成而非重新构建的策略。也就是说order capture, inventory management, order management, fulfillment, and reporting 这些都购买现成的厂商的,我们只需要集中开发一个内容管理系统。

    一个基于Mule的企业服务总线的案例

    通过和其它六家厂商的协商,他们都提供了JMS和SOAP的接口。因此我们需要一个专业的JMS服务器。

    下面我们来看看配置文件:

    mule-configurationid="Enterprise-Applications-Mashup"version="1.0">
    首先定义一个Mule和JMS交互的连接器,相当于一个连接池
    connectorname="jmsConnector"className="org.mule.providers.jms.JmsConnector">
    properties>
    propertyname="jndiProviderUrl"
    value
    ="bitjmsnaming://172.28.63.209:7222"/>
    propertyname="connectionFactoryJndiName"
    value
    ="QueueConnectionFactory"/>
    mapname="jndiProviderProperties">
    propertyname="java.naming.factory.initial"
    value
    ="com.bitco.bitjms.naming.bitjmsInitialContextFactory"/>
    propertyname="java.naming.security.principal"value="admin"/>
    propertyname="java.naming.security.credentials"value=""/>
    map>
    propertyname="username"value="admin"/>
    propertyname="password"value=""/>
    properties>
    connector>
    然后定义一些端点,每个端点都是一个外部供应商程序的接口
    global-endpoints>
    endpointname="inJMSGTA"address="jms://q.gta.in"connector="jmsConnector"/>
    endpointname="inJMSSeebelle"address="jms://q.seebelle.in"connector="jmsConnector"/>
    endpointname="inJMSYenta"address="jms://q.yenta.in"connector="jmsConnector"/>
    endpointname="inJMSCatwire"address="jms://q.catwire.in"connector="jmsConnector"/>
    endpointname="inJMSBitco"address="jms://q.bitco.in"connector="jmsConnector"/>
    endpointname="outJMSGTA"address="jms://q.gta.out"connector="jmsConnector"/>
    endpointname="outJMSSeebelle"address="jms://q.seebelle.out"connector="jmsConnector"/>
    endpointname="outJMSYenta"address="jms://q.yenta.out"connector="jmsConnector"/>
    endpointname="outJMSCatwire"address="jms://q.catwire.out"connector="jmsConnector"/>
    endpointname="outJMSBitco"address="jms://q.bitco.out"connector="jmsConnector"/>
    endpointname="console"address="stream://System.out"/>
    global-endpoints>

    transformers>
    transformername="JMSMessageToObject"
    className
    ="org.mule.providers.jms.transformers.JMSMessageToObject"/>
    transformername="ObjectToString"
    className
    ="org.mule.transformers.simple.ObjectToString"/>
    transformers>

    modelname="Enterprise-Applications-Mashup-JMS">
    mule-descriptorname="JMSMessageSwitchboard"
    implementation
    ="org.mule.components.simple.PassThroughComponent">
    系统只有一个inbound,也就是进入系统消息的定义,端口名称叫做outJMSBitco,也就是说outJMSBitco发出一个指令,进入总线,然后Mule把这个消息转换后发送给其它所有的outbound-router,离开总线,进入别的应用程序。
    inbound-router>
    global-endpointname="outJMSBitco"/>
    inbound-router>

    outbound-routermatch-all="true">
    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSYenta"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"
    expression
    ="OrderHistoryRequest"/>
    router>
    以下面这条为例:
    这条路由的意思是,将消息通过JMS发送给Siebel,JMS的头要标上OrderHistoryResonse,这样Siebel的消息队列受到一条这个消息,Siebel知道对方要做什么操作,将OrderHistory查询出来。
    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSSiebel"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"
    expression
    ="OrderHistoryResponse"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSCatwire"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="item"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSCatwire"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="item_mapping"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSYenta"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="PAMInventoryUpdate"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSGTA"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="CustomerSearchRequest"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSSiebel"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="CustomerSearchResponse"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSYenta"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="OrderDetailsRequest"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSSiebel"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="OrderDetailsResponse"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSYenta"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="OrderAddUpdRequest"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSSiebel"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="OrderAddUpdResponse"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSYenta"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="catwireCreateItem"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSGTA"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="catalogupdate"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSGTA"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="productupdate"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSGTA"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="skuupdate"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSYenta"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="gtaCreateOrder"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSYenta"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="gtaGetOrderDetails"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="openJmsOutbound"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="XXXOrderUpdate"/>
    router>

    routerclassName="org.mule.routing.outbound.FilteringOutboundRouter">
    global-endpointname="inJMSBitco"/>
    filterclassName="org.mule.samples.jms.JMSHeaderFilter"expression="OrderRelease"/>
    router>
    这个端口的意思是把消息打印在DOS窗口上
    routerclassName="org.mule.routing.outbound.OutboundPassThroughRouter">
    endpointaddress="stream://System.out"transformers="ObjectToString"/>
    router>
    outbound-router>
    mule-descriptor>
    model>
    mule-configuration>




    你可能感兴趣的:(应用服务器,jms,企业应用,SOAP,websphere)