Dubbo Service Management configuration Zookeeper Cluster service __java

Source: Internet
Author: User
Tags zookeeper

Dubbo How to use please refer to my previous article: Dubbo Distributed Service Framework and Springmvc+zookeeper implementation service delivery and consumption

This article continues to delve into the previous content and to organize more detailed documentation: http://pan.baidu.com/s/1kUMx3in
Dubbo and Zookeeper cluster architecture

Tomcat registration service to zookeeper Cluster, managed by Dubbo. Dubbo Configuration Zookeeper

To modify the Dubbo/web-inf/dubbo.properties file:

dubbo.registry.address=zookeeper://192.168.200.122:2181?backup=192.168.200.122:2182,192.168.200.122:2183

Dubbo.admin.root.password=root

Dubbo.admin.guest.password=guest

Configuring the Provider-customer node Node1

Provider Applicationcontext.xml

<?xmlversion= "1.0" encoding= "UTF-8"?> "<beansxmlns=" 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/dub

 

    Bo/dubbo.xsd "> <!--provider application information, used to compute dependencies--> <dubbo:applicationname=" Webapp-api-provider "/> <!--use zookeeper Registry to expose service address--> <!--<dubbo:registryaddress= "zookeeper://192.168.200.122:2181?"/>--&

   

    Gt <!--Zookeeper Registration center exposes service cluster configuration--> <dubbo:registryaddress= "zookeeper://192.168.200.122:2181?backup= 192.168.200.122:2182,192.168.200.122:2183 "/> <!--exposes services on port 20881 with the Dubbo protocol (the port number cannot be duplicated if there are multiple providers)--> <

 

 Dubbo:protocol name= "Dubbo" port= "20881"/>   <!--declare the service interface that needs to be exposed (interface is a full path name and cannot be customized)--> <dubbo:serviceinterface= "Dubbo.web.api.service.UserService" re f= "UserService"/> <!--implements services like local beans--> <bean id= "UserService" class= "Com.boonya.dubbo.provider.Use" Rserviceprovider "/> <!--declare the service interfaces that need to be exposed (interface is a full path name, cannot be customized)--> <dubbo:serviceinterface=" Dubbo.web.ap I.service.productservice "ref=" Productservice/> <!--and local bean implementation Services--> <bean id= "Productservice" cl ass= "Com.boonya.dubbo.provider.ProductServiceProvider"/> </beans>

Customer Applicationcontext.xml

<?xmlversion= "1.0" encoding= "UTF-8"?> "<beansxmlns=" 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/dub

 

    Bo/dubbo.xsd "> <!--consumer application information, used to compute dependencies--> <dubbo:applicationname=" Webapp-api-customer "/> <!--use zookeeper Registry to expose service address--> <!--<dubbo:registryaddress= "zookeeper://192.168.200.122:2181"/>--&

    Gt <!--Zookeeper Registration center exposes service cluster configuration--> <dubbo:registryaddress= "zookeeper://192.168.200.122:2181?backup= 192.168.200.122:2182,192.168.200.122:2183 "/> <!--generate a remote service proxy that can be used like a local bean userservice--> <dubbo:refer Enceid= "UserService" interface= "Dubbo.web.api.service.UserSerVice "/> <dubbo:referenceid=" Productservice "interface=" Dubbo.web.api.service.ProductService "/> </bean S>


Node2 Provider Applicationcontext.xml

<?xmlversion= "1.0" encoding= "UTF-8"?> "<beansxmlns=" 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/dub

 

    Bo/dubbo.xsd "> <!--provider application information, used to compute dependencies--> <dubbo:applicationname=" Webapp-api-provider "/> <!--use zookeeper Registry to expose service address--> <!--<dubbo:registryaddress= "zookeeper://192.168.200.122:2181?"/>--&

   

    Gt <!--Zookeeper Registration center exposes service cluster configuration--> <dubbo:registryaddress= "zookeeper://192.168.200.122:2181?backup= 192.168.200.122:2182,192.168.200.122:2183 "/> <!--exposes services on port 20881 with the Dubbo protocol (the port number cannot be duplicated if there are multiple providers)--> <

 

 Dubbo:protocol name= "Dubbo" port= "20882"/>   <!--declare the service interface that needs to be exposed (interface is a full path name and cannot be customized)--> <dubbo:serviceinterface= "Dubbo.web.api.service.UserService" re f= "UserService"/> <!--implements services like local beans--> <bean id= "UserService" class= "Com.boonya.dubbo.provider.Use" Rserviceprovider "/> <!--declare the service interfaces that need to be exposed (interface is a full path name, cannot be customized)--> <dubbo:serviceinterface=" Dubbo.web.ap I.service.productservice "ref=" Productservice/> <!--and local bean implementation Services--> <bean id= "Productservice" cl ass= "Com.boonya.dubbo.provider.ProductServiceProvider"/> </beans>

Customer Applicationcontext.xml

<?xmlversion= "1.0" encoding= "UTF-8"?> "<beansxmlns=" 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/dub

 

    Bo/dubbo.xsd "> <!--consumer application information, used to compute dependencies--> <dubbo:applicationname=" Webapp-api-customer "/> <!--use zookeeper Registry to expose service address--> <!--<dubbo:registryaddress= "zookeeper://192.168.200.122:2181"/>--&

    Gt <!--Zookeeper Registration center exposes service cluster configuration--> <dubbo:registryaddress= "zookeeper://192.168.200.122:2181?backup= 192.168.200.122:2182,192.168.200.122:2183 "/> <!--generate a remote service proxy that can be used like a local bean userservice--> <dubbo:refer Enceid= "UserService" interface= "Dubbo.web.api.service.UserSerVice "/> <dubbo:referenceid=" Productservice "interface=" Dubbo.web.api.service.ProductService "/> </bean S>

Node3 Provider Applicationcontext.xml
<?xmlversion= "1.0" encoding= "UTF-8"?> "<beansxmlns=" 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/dub

 

    Bo/dubbo.xsd "> <!--provider application information, used to compute dependencies--> <dubbo:applicationname=" Webapp-api-provider "/> <!--use zookeeper Registry to expose service address--> <!--<dubbo:registryaddress= "zookeeper://192.168.200.122:2181?"/>--&

   

    Gt <!--Zookeeper Registration center exposes service cluster configuration--> <dubbo:registryaddress= "zookeeper://192.168.200.122:2181?backup= 192.168.200.122:2182,192.168.200.122:2183 "/> <!--exposes services on port 20881 with the Dubbo protocol (the port number cannot be duplicated if there are multiple providers)--> <

 

 Dubbo:protocol name= "Dubbo" port= "20883"/>   <!--declare the service interface that needs to be exposed (interface is a full path name and cannot be customized)--> <dubbo:serviceinterface= "Dubbo.web.api.service.UserService" re f= "UserService"/> <!--implements services like local beans--> <bean id= "UserService" class= "Com.boonya.dubbo.provider.Use" Rserviceprovider "/> <!--declare the service interfaces that need to be exposed (interface is a full path name, cannot be customized)--> <dubbo:serviceinterface=" Dubbo.web.ap I.service.productservice "ref=" Productservice/> <!--and local bean implementation Services--> <bean id= "Productservice" cl ass= "Com.boonya.dubbo.provider.ProductServiceProvider"/> </beans>

Customer Applicationcontext.xml

<?xmlversion= "1.0" encoding= "UTF-8"?> "<beansxmlns=" 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/dub

 

    Bo/dubbo.xsd "> <!--consumer application information, used to compute dependencies--> <dubbo:applicationname=" Webapp-api-customer "/> <!--use zookeeper Registry to expose service address--> <!--<dubbo:registryaddress= "zookeeper://192.168.200.122:2181"/>--&

    Gt <!--Zookeeper Registration center exposes service cluster configuration--> <dubbo:registryaddress= "zookeeper://192.168.200.122:2181?backup= 192.168.200.122:2182,192.168.200.122:2183 "/> <!--generate a remote service proxy that can be used like a local bean userservice--> <dubbo:refer Enceid= "UserService" interface= "Dubbo.web.api.service.UserSerVice "/> <dubbo:referenceid=" Productservice "interface=" Dubbo.web.api.service.ProductService "/> </bean S>

Test Node API Services

Providers

Customers

Note: Once you have access to the interface, you can see the consumer, where the "application name" can be differentiated according to the port settings for Tomcat. Dubbo+zookeeper Architecture Application Framework

Website address: http://minglisoft.cn/technology/index.htm

360 Library Introduction: http://www.360doc.com/content/17/0511/15/36031295_652993734.shtml
Latest Sample code download
Github:https://github.com/sunflowersofjava/dubbo-zookeeper-spring.git

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.