dubbo服务者配置说明

来源:互联网 发布:java.util.zip 加密 编辑:程序博客网 时间:2024/06/13 09:55
<?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.heli.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.heli.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>

0 0
原创粉丝点击