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
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