dubbo服務者配置說明

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!-- - Copyright 1999-2011 Alibaba Group. - - Licensed under the Apache License,   
  3.     Version 2.0 (the "License"); - you may not use this file except in compliance   
  4.     with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0   
  5.     - - Unless required by applicable law or agreed to in writing, software -   
  6.     distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT   
  7.     WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the   
  8.     License for the specific language governing permissions and - limitations   
  9.     under the License. -->  
  10. <beans xmlns="http://www.springframework.org/schema/beans"  
  11.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"  
  12.     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
  13.     http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">  
  14.       
  15.     <!-- 引入spring配置 -->  
  16.     <import resource="applicationContext.xml" />  
  17.     <!-- 具體服務實現bean -->  
  18.     <bean id="userService" class="com.heli.user.service.impl.UserServiceImpl" />  
  19.     <!-- 將服務service封裝成可以對外開放的服務, 同時提供負載均衡算法,loadbalance可選有random,roundrobin(輪詢) -->  
  20.     <!--service中加入   mock="return null"當service所有都掛掉以後,client調用時自動獲取到return null -->  
  21.     <!--service中加入 actives="10" 表示限制所有服務在每個客戶端調用都不能同時超過10個 -->  
  22.     <!--service中加入  executes="10" 表示限制所有服務在每個服務器端被調用都不能同時超過10個 -->  
  23.     <!-- 可以在service中加入內部標籤   <dubbo:method name="sayHello" actives="10" />來控制每個方法的執行併發個數 -->  
  24.     <!-- timeout="300" retry="2" 超時時間300    重試2次 -->  
  25.     <!-- owner=”WangHeping,Guoyong”該服務的負責人 -->  
  26.     <dubbo:service interface="com.heli.user.service.IUserService" ref="userService" loadbalance="roundrobin" />  
  27.     <!-- 提供方應用信息,用於計算依賴關係,不要與消費方一樣 -->  
  28.     <dubbo:application name="MyFirstDubboProvider" />  
  29.     <!-- 使用multicast廣播註冊中心暴露服務地址 <dubbo:registry address="multicast://224.5.6.7:1234"   
  30.         /> -->  
  31.     <!-- 使用zookeeper註冊中心暴露服務地址 -->  
  32.     <dubbo:registry address="zookeeper://192.168.1.244:2181" />  
  33.     <!-- 用dubbo協議在20880端口暴露服務 ,注意不能與其他服務端口相同  -->  
  34.     <!-- dispatcher all所有請求都發到線程池處理,threadpool fixed固定線程池大小,初始化後不進行伸縮,threads 線程池內線程個數 -->  
  35.     <!-- <dubbo:protocol accesslog="true" />開啓訪問日誌記錄 -->  
  36.     <!-- <dubbo:protocol accesslog="http://10.20.160.198/wiki/display/dubbo/foo/bar.log" />規定訪問日誌的路徑 -->  
  37.     <!-- <dubbo:protocol name="dubbo" connections="2" accepts="1000"/> dubbo協議使用長連接和nio,這裏connections=2表示同時建立兩個長連接(要在provier和consumer同時寫上)  
  38.         accepts=1000  表示爲了防止同時過來大量連接而被幹掉,限制最大爲1000-->  
  39.     <dubbo:protocol name="dubbo" port="20880" dispatcher="all" threadpool="fixed" threads="100" />  
  40.   
  41. </beans>  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章