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

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

      
    < transformers >  
        
    < transformer  name ="JMSMessageToObject"
                     className
    ="org.mule.providers.jms.transformers.JMSMessageToObject"   />  
        
    < transformer  name ="ObjectToString"
                     className
    ="org.mule.transformers.simple.ObjectToString"   />  
      
    </ transformers >  

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

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

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSCatwire" />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="item"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSCatwire" />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="item_mapping"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSYenta" />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="PAMInventoryUpdate"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSGTA"   />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="CustomerSearchRequest"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSSiebel"   />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="CustomerSearchResponse"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSYenta"   />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="OrderDetailsRequest"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSSiebel"   />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="OrderDetailsResponse"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSYenta"   />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="OrderAddUpdRequest"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSSiebel"   />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="OrderAddUpdResponse"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSYenta"   />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="catwireCreateItem"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSGTA"   />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="catalogupdate"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSGTA"   />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="productupdate"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSGTA"   />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="skuupdate"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSYenta"   />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="gtaCreateOrder"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="inJMSYenta"   />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="gtaGetOrderDetails"   />  
            
    </ router >              

            
    < router  className ="org.mule.routing.outbound.FilteringOutboundRouter" >  
              
    < global-endpoint  name ="openJmsOutbound" />  
              
    < filter  className ="org.mule.samples.jms.JMSHeaderFilter"  expression ="XXXOrderUpdate"   />  
            
    </ router >              

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

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