<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
	http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"
	   default-autowire="byName">

    <!-- 这里的配置将覆盖properties里的配置 -->
	<!--&lt;!&ndash; 提供方应用信息，用于计算依赖关系 &ndash;&gt;-->
	<!--<dubbo:application name="whatsmars_provider" />-->
	<!--&lt;!&ndash; 使用zookeeper注册中心暴露服务地址 &ndash;&gt;-->
	<!--<dubbo:registry address="zookeeper://127.0.0.1:2181" />-->

    <!-- 多协议配置，一种协议只能对应一种序列化方式，建议用hessian2序列化
    （也是官方推荐，出于稳定性和性能的折中考虑）
     序列化方式由provider决定，所以团队要决定改序列化方式时，只需修改provider配置 -->
    <dubbo:protocol name="dubbo" port="20880" server="netty4" />
	<dubbo:protocol name="hessian" port="8080" server="jetty" />

	<context:component-scan base-package="org.hongxi.whatsmars.dubbo"/>

	<!-- provider用于统一配置全部service，优先级service > provider -->
	<dubbo:provider timeout="3000" />

    <!-- 默认配了 protocol="dubbo,hessian" 默认retries="2" -->
	<dubbo:service interface="org.hongxi.whatsmars.dubbo.demo.api.DemoService" ref="demoService"
                   timeout="500" retries="2" />

	<!-- 类似group的还有version="2.0.0" -->
	<dubbo:service group="new" interface="org.hongxi.whatsmars.dubbo.demo.api.DemoService" ref="demoService2" protocol="dubbo" />

	<!-- 通过loadbalance="leastactive"也可实现并发控制，此 Loadbalance 会调用并发数最小的 Provider(Consumer端并发数) -->
	<dubbo:service interface="org.hongxi.whatsmars.dubbo.demo.api.BarService" ref="barService"
	mock="org.hongxi.whatsmars.dubbo.demo.provider.BarServiceMock" executes="10" protocol="dubbo" />

</beans>