皮杜妮

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            887 Posts :: 3 Stories :: 7 Comments :: 0 Trackbacks
          做系統集成新的方式,主要是消息處理機制,采用通道的方式。



          簡單的配置文件
          <beans:beans xmlns="http://www.springframework.org/schema/integration"
              xmlns:xsi
          ="http://www.w3.org/2001/XMLSchema-instance"
              xmlns:beans
          ="http://www.springframework.org/schema/beans"
              xmlns:context
          ="http://www.springframework.org/schema/context"
              xsi:schemaLocation
          ="http://www.springframework.org/schema/beans
                  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                  http://www.springframework.org/schema/integration
                  http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
                  http://www.springframework.org/schema/context
                  http://www.springframework.org/schema/context/spring-context-2.5.xsd"
          >

              
          <!-- 啟動Message bus 消息服務總線 支持四個屬性 
                      auto-startup[boolean是否自動啟動 default=true]如果設置false,則需要手動調用applicationContext.start()方法
                      auto-create-channels[boolean是否自動注冊MessageChannel default=false],如果使用的MessagChannle不存在
                      error-channel 設置錯誤時信息發送的MessageChannle,如果不設置,則使用DefaultErrorChannel
                      dispatcher-pool-size 使用的啟動線程數,默認為10
          -->
              
          <message-bus/>
              
          <!-- 啟動支持元數據標記 -->
              
          <annotation-driven/>
              
          <!-- 設置 @Component標識的元數據掃描包(package) -->
              
          <context:component-scan base-package="org.springframework.integration.samples.cafe"/>

                  
          <!-- 下面啟動了四個 MessageChannel服務 處理接收發送端發過來的消息和把消息流轉到消息的消費端 -->
                  
          <!-- 屬性說明: capacity 消息最大容量默認為100 publish-subscribe是否是發布訂閱模式,默認為否
                                                  id bean的id名稱 datatype ? 
          -->
              
          <channel id="orders"/> <!-- 訂單Channel -->
              
          <channel id="drinks"/> <!-- 飲料訂單Channel,處理飲料的類別 -->
              
          <channel id="coldDrinks"/> <!-- 熱飲生產Channel -->
              
          <channel id="hotDrinks"/> <!-- 冷飲生產Channel -->

                  
          <!-- 消息處理終端 接收 channel coldDrinks的消息后,執行barista.prepareColdDrink方法 生產冷飲 -->
                  
          <!-- 屬性說明: input-channel 接收消息的Channel必須 default-output-channel設置默認回復消息Channel
                                                  handler-ref 引用bean的id名稱 handler-method Handler處理方法名(參數類型必須與發送消息的payLoad使用的一致)
                                                  error-handler設置錯誤時信息發送的MessageChannle   reply-handler 消息回復的Channel 
          -->
              
          <endpoint input-channel="coldDrinks" handler-ref="barista"
                                                   handler-method
          ="prepareColdDrink"/>

                  
          <!-- 消息處理終端 接收 channel hotDrinks的消息后,執行barista.prepareHotDrink方法 生產熱飲 -->
              
          <endpoint input-channel="hotDrinks" handler-ref="barista"
                                                  handler-method
          ="prepareHotDrink"/>

                  
          <!-- 定義一個啟動下定單操作的bean,它通過 channel orders下定單 -->
              
          <beans:bean id="cafe" class="org.springframework.integration.samples.cafe.Cafe">
                  
          <beans:property name="orderChannel" ref="orders"/>
              
          </beans:bean>
          </beans:beans>
          posted on 2013-11-28 16:15 豬眼睛 閱讀(170) 評論(0)  編輯  收藏 所屬分類: Spring
          主站蜘蛛池模板: 花莲县| 遵化市| 林周县| 乾安县| 尚志市| 察哈| 庆云县| 峨边| 泰来县| 江永县| 威远县| 精河县| 高清| 北辰区| 澜沧| 新化县| 来安县| 黑龙江省| 克什克腾旗| 孟州市| 瓦房店市| 桃园市| 棋牌| 麻江县| 阜南县| 新泰市| 江达县| 长丰县| 城固县| 怀远县| 深水埗区| 华蓥市| 玛曲县| 临汾市| 吉安市| 普兰县| 巨鹿县| 桐庐县| 连平县| 浑源县| 绥中县|