Building a simple environment for Dubbo learning and building a Dubbo + zookeeper platform from scratch

Development and role of Dubbo services:

Simple environment construction of Dubbo

1. Installing zookeeper

Zookeeper download address: http://www.apache.org/dyn/closer.cgi/zookeeper/ , download and unzip to run. Note that there is no configuration file for zookeeper in the conf folder under the zookeeper directory, but there is a zoo_ sample. Cfg file and change its command to zoo CFG to use the default configuration.

Click zkserver CMD start zookeeper:

2. Install Dubbo admin war

Install Dubbo admin War is not necessary, but using Dubbo admin can easily view the operation status and data of Dubbo and facilitate management. After downloading, put it into the webapps directory of Tomcat and start Tomcat to access Dubbo. After logging in, you can see the following page (the login user name and password are viewed in dubbo.properties file):

3. Dubbo server configuration

Create a new Dubbo server project, download the required jar package, write the service interface and implementation class, and then expose the service through the zookeeper registry.

(3.1) add the dependency of the required jar package in the Maven file:

(3.2) the project spring file (ApplicationContext. XML) is configured as follows:

(3.3) external service interface and its implementation class:

(3.4) startup:

The whole Dubbo server project structure is as follows:

4. Dubbo client side configuration

Create a new Dubbo client project, download the required jar package, write the interface to obtain the service, and then obtain it through the service exposed in the zookeeper registry.

(4.1) add the dependency of the required jar package in the Maven file:

(4.2) the project spring file (ApplicationContext. XML) is configured as follows:

(4.3) interface of service to be obtained:

(4.4) startup

The whole Dubbo server project structure is as follows:

@H_ 833_ 403@

After running the clientstart class, the output is as follows:

be careful:

First run zookeeper, then start the Dubbo server program, and finally run the Dubbo client program. The service interface path in the Dubbo client must be consistent with that in the Dubbo server, that is, the URL of a class in the Dubbo server and the URL in the Dubbo client must be the same, otherwise a forbid consumer exception will appear during operation.

reference resources:

1. Detailed graphic tutorial of zookeeper Dubbo installation + configuration + demo under Windows

2. Build a Dubbo + zookeeper platform from scratch

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>