當前位置:
首頁 >
Dubbo xml配置 和注解配置 写法
發布時間:2023/12/10
47
豆豆
生活随笔
收集整理的這篇文章主要介紹了
Dubbo xml配置 和注解配置 写法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<?xml version="1.0" encoding="UTF-8"?>
<!-- - Copyright 1999-2011 Alibaba Group. - - Licensed under the Apache License,
Version 2.0 (the "License"); - you may not use this file except in compliance
with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0
- - Unless required by applicable law or agreed to in writing, software -
distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the
License for the specific language governing permissions and - limitations
under the License. -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- 引入spring配置 -->
<import resource="applicationContext.xml" />
<!-- 具體服務實現bean -->
<bean id="userService" class="com.xxx.user.service.impl.UserServiceImpl" />
<!-- 將服務service封裝成可以對外開放的服務, 同時提供負載均衡算法,loadbalance可選有random,roundrobin(輪詢) -->
<!--service中加入 mock="return null"當service所有都掛掉以后,client調用時自動獲取到return null -->
<!--service中加入 actives="10" 表示限制所有服務在每個客戶端調用都不能同時超過10個 -->
<!--service中加入 executes="10" 表示限制所有服務在每個服務器端被調用都不能同時超過10個 -->
<!-- 可以在service中加入內部標簽 <dubbo:method name="sayHello" actives="10" />來控制每個方法的執行并發個數 -->
<!-- timeout="300" retry="2" 超時時間300 重試2次 -->
<!-- owner=”WangHeping,Guoyong”該服務的負責人 -->
<dubbo:service interface="com.xxx.user.service.IUserService" ref="userService" loadbalance="roundrobin" />
<!-- 提供方應用信息,用于計算依賴關系,不要與消費方一樣 -->
<dubbo:application name="MyFirstDubboProvider" />
<!-- 使用multicast廣播注冊中心暴露服務地址 <dubbo:registry address="multicast://224.5.6.7:1234"
/> -->
<!-- 使用zookeeper注冊中心暴露服務地址 -->
<dubbo:registry address="zookeeper://192.168.1.244:2181" />
<!-- 用dubbo協議在20880端口暴露服務 ,注意不能與其他服務端口相同 -->
<!-- dispatcher all所有請求都發到線程池處理,threadpool fixed固定線程池大小,初始化后不進行伸縮,threads 線程池內線程個數 -->
<!-- <dubbo:protocol accesslog="true" />開啟訪問日志記錄 -->
<!-- <dubbo:protocol accesslog="http://10.20.160.198/wiki/display/dubbo/foo/bar.log" />規定訪問日志的路徑 -->
<!-- <dubbo:protocol name="dubbo" connections="2" accepts="1000"/> dubbo協議使用長連接和nio,這里connections=2表示同時建立兩個長連接(要在provier和consumer同時寫上)
accepts=1000 表示為了防止同時過來大量連接而被干掉,限制最大為1000-->
<dubbo:protocol name="dubbo" port="20880" dispatcher="all" threadpool="fixed" threads="100" />
</beans>
<!-- - Copyright 1999-2011 Alibaba Group. - - Licensed under the Apache License,
Version 2.0 (the "License"); - you may not use this file except in compliance
with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0
- - Unless required by applicable law or agreed to in writing, software -
distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the
License for the specific language governing permissions and - limitations
under the License. -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- 引入spring配置 -->
<import resource="applicationContext.xml" />
<!-- 具體服務實現bean -->
<bean id="userService" class="com.xxx.user.service.impl.UserServiceImpl" />
<!-- 將服務service封裝成可以對外開放的服務, 同時提供負載均衡算法,loadbalance可選有random,roundrobin(輪詢) -->
<!--service中加入 mock="return null"當service所有都掛掉以后,client調用時自動獲取到return null -->
<!--service中加入 actives="10" 表示限制所有服務在每個客戶端調用都不能同時超過10個 -->
<!--service中加入 executes="10" 表示限制所有服務在每個服務器端被調用都不能同時超過10個 -->
<!-- 可以在service中加入內部標簽 <dubbo:method name="sayHello" actives="10" />來控制每個方法的執行并發個數 -->
<!-- timeout="300" retry="2" 超時時間300 重試2次 -->
<!-- owner=”WangHeping,Guoyong”該服務的負責人 -->
<dubbo:service interface="com.xxx.user.service.IUserService" ref="userService" loadbalance="roundrobin" />
<!-- 提供方應用信息,用于計算依賴關系,不要與消費方一樣 -->
<dubbo:application name="MyFirstDubboProvider" />
<!-- 使用multicast廣播注冊中心暴露服務地址 <dubbo:registry address="multicast://224.5.6.7:1234"
/> -->
<!-- 使用zookeeper注冊中心暴露服務地址 -->
<dubbo:registry address="zookeeper://192.168.1.244:2181" />
<!-- 用dubbo協議在20880端口暴露服務 ,注意不能與其他服務端口相同 -->
<!-- dispatcher all所有請求都發到線程池處理,threadpool fixed固定線程池大小,初始化后不進行伸縮,threads 線程池內線程個數 -->
<!-- <dubbo:protocol accesslog="true" />開啟訪問日志記錄 -->
<!-- <dubbo:protocol accesslog="http://10.20.160.198/wiki/display/dubbo/foo/bar.log" />規定訪問日志的路徑 -->
<!-- <dubbo:protocol name="dubbo" connections="2" accepts="1000"/> dubbo協議使用長連接和nio,這里connections=2表示同時建立兩個長連接(要在provier和consumer同時寫上)
accepts=1000 表示為了防止同時過來大量連接而被干掉,限制最大為1000-->
<dubbo:protocol name="dubbo" port="20880" dispatcher="all" threadpool="fixed" threads="100" />
</beans>
轉載于:https://www.cnblogs.com/wangdaijun/p/6026551.html
總結
以上是生活随笔為你收集整理的Dubbo xml配置 和注解配置 写法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 浅谈SQL注入的四种防御方法
- 下一篇: 机器人离线编程画圆误差解决方案_工业机器