Dubbo-多协议,多注册中心配置

1.不同服务在性能上适用不同协议进行传输

1.1 服务提供者配置

<?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:dubbo="http://code.alibabatech.com/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        ">     
     <!-- 提供方应用信息,用于计算依赖关系,这个和client没必要一致 -->
	<dubbo:application name="hello-world-app-my" />
   <dubbo:registry  protocol="zookeeper"  address="192.168.0.101:2181"/>
     <!-- 用dubbo协议在20880端口暴露服务 -->
   	<dubbo:protocol name="dubbo" port="20880" />  
   	 <!-- 用rmi协议在20881端口暴露服务 -->   
   	<dubbo:protocol name="rmi" port="20881" />  
   	 <!-- 声明需要暴露的服务接口 -->
	<dubbo:service  interface="com.test.dubboser.ServiceDemo"
		ref="demoService" protocol="dubbo" /> 
	<dubbo:service  interface="com.test.dubboser.ServiceDemo2"
		ref="demoService2" protocol="rmi" /> 
    <!--和本地bean一样实现服务 -->
	<bean id="demoService" class="com.test.dubboser.ServiceImp"/>
	<bean id="demoService2" class="com.test.dubboser.ServiceImp2"/>
	
</beans>

        从这些配置我们看到,不同服务使用不同的协议,这种配置方式和其他的配置方式是一样的

1.2 服务消费者配置

<?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:dubbo="http://code.alibabatech.com/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        ">     
	<!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 -->
	<dubbo:application name="consumer-of-helloworld-app-my" />     
	   <!-- 使用zookeeper广播注册中心暴露发现服务地址 -->
	<dubbo:registry  protocol="zookeeper"  address="192.168.0.101:2181" />    
    <dubbo:reference id="demoServicemy"    interface="com.test.dubboser.ServiceDemo"/>
    <dubbo:reference id="demoServicemy2"   interface="com.test.dubboser.ServiceDemo2"/>
</beans>

 

        消费端还是按照正常方式获取服务,只是传递使用的协议不同,底层tcp链接时常不同……

 

2.同一服务多协议配置

2.1 服务提供者配置

<?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:dubbo="http://code.alibabatech.com/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        ">     
     <!-- 提供方应用信息,用于计算依赖关系,这个和client没必要一致 -->
	<dubbo:application name="hello-world-app-my" />
   <dubbo:registry  protocol="zookeeper"  address="192.168.0.101:2181"/>
     <!-- 用dubbo协议在20880端口暴露服务 -->
   	<dubbo:protocol name="dubbo" port="20880" />     
   	<dubbo:protocol name="rmi" port="20881" />  
   	 <!-- 声明需要暴露的服务接口 -->
	<dubbo:service  interface="com.test.dubboser.ServiceDemo"
		ref="demoService" protocol="dubbo,rmi" /> 
    <!--和本地bean一样实现服务 -->
	<bean id="demoService" class="com.test.dubboser.ServiceImp"/>
	
</beans>

2.2 服务消费者配置

<?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:dubbo="http://code.alibabatech.com/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        ">     
	<!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 -->
	<dubbo:application name="consumer-of-helloworld-app-my" />     
	   <!-- 使用zookeeper广播注册中心暴露发现服务地址 -->
	<dubbo:registry  protocol="zookeeper"  address="192.168.0.101:2181" />    
    <dubbo:reference id="demoServicemy3"    interface="com.test.dubboser.ServiceDemo"/>
</beans>

 

3.不同服务注册到不同的注册中心

3.1 服务提供者配置

<?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:dubbo="http://code.alibabatech.com/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        ">     
     <!-- 提供方应用信息,用于计算依赖关系,这个和client没必要一致 -->
	<dubbo:application name="hello-world-app-my" />
	<!-- 多注册中心配置 -->
   <dubbo:registry  id="bjregister" protocol="zookeeper"  address="192.168.0.101:2181"/>
   <dubbo:registry  id="shregister" protocol="zookeeper"  address="192.168.0.101:2182"/>
     <!-- 用dubbo协议在20880端口暴露服务 -->
   	<dubbo:protocol name="dubbo" port="20880" />  
   	 <!-- 声明需要暴露的服务接口 -->
   	 <!--不同服务注册到不同的注册中心  -->
	<dubbo:service  interface="com.test.dubboser.ServiceDemo"
		ref="demoService"  registry="bjregister" /> 
	<dubbo:service  interface="com.test.dubboser.ServiceDemo2"
		ref="demoService2" registry="shregister"/> 
    <!--和本地bean一样实现服务 -->
	<bean id="demoService" class="com.test.dubboser.ServiceImp"/>
	<bean id="demoService2" class="com.test.dubboser.ServiceImp2"/>
	
</beans>

3.2 服务消费者配置文件

<?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:dubbo="http://code.alibabatech.com/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        ">     
	<!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 -->
	<dubbo:application name="consumer-of-helloworld-app-my" />     
	<!-- 使用zookeeper广播注册中心暴露发现服务地址 -->
	<!--向两个注册中心订阅  -->
	<dubbo:registry  protocol="zookeeper"  address="192.168.0.101:2181"/>  
	<dubbo:registry  protocol="zookeeper"  address="192.168.0.101:2182"/>   
	<!--获取服务  -->
    <dubbo:reference id="demoServicemy"    interface="com.test.dubboser.ServiceDemo"/>
    <dubbo:reference id="demoServicemy2"   interface="com.test.dubboser.ServiceDemo2"/>
</beans>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
dubbo-admin-0.0.1-snapshot.jar 是一个Dubbo框架的管理工具。Dubbo是一种高性能的分布式服务框架,用于构建微服务架构。Dubbo-admin提供了一个图形化界面,用于管理和监控Dubbo框架下的微服务。 dubbo-admin-0.0.1-snapshot.jar 将Dubbo的主要功能封装在一个可执行的JAR文件中,方便安装和部署。它提供了以下几个主要功能: 1. 服务管理:Dubbo-admin可以展示当前Dubbo框架中已注册的所有服务,包括服务的接口、提供者和消费者信息。它可以帮助开发人员和运维人员了解系统中的服务情况,识别问题和解决故障。 2. 消费者监控:Dubbo-admin可以实时监控消费者对服务的调用情况,包括调用次数、成功率、调用耗时等指标。通过监控消费者行为,可以发现潜在的性能瓶颈和系统故障,并及时采取措施加以解决。 3. 负载均衡:Dubbo-admin提供了负载均衡配置的功能,可以根据不同的负载均衡策略来分配服务请求到不同的提供者。这可以帮助开发人员根据不同的业务需求配置合适的负载均衡策略,提高系统的性能和可靠性。 4. 配置管理:Dubbo-admin可以管理Dubbo框架的各种配置,包括注册中心协议和服务等。通过配置管理,开发人员可以根据具体需求进行灵活的设置和调整,以满足不同的业务场景。 总的来说,dubbo-admin-0.0.1-snapshot.jar 是一个方便管理和监控Dubbo框架下微服务的工具。它提供了服务管理、消费者监控、负载均衡和配置管理等功能,帮助开发人员和运维人员更好地了解和管理系统的服务。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值