Dubbo Introduction Example (ii)

Source: Internet
Author: User

Dubbo Installation

: https://github.com/alibaba/dubbo/releases

Pom.xml:http://files.cnblogs.com/files/belen/pom.xml

Zookeeper (Registration Center)

Pom.xml

<dependency>

<groupId>org.apache.zookeeper</groupId>

<artifactId>zookeeper</artifactId>

<version>3.4.6</version>

</dependency>

Zookeeper is a distributed, open source distributed application Coordination Service that is an open source implementation of Google's chubby and an important component of Hadoop and HBase.

instance, zookeeper will serve as the registry for the Dubbo service. Also responsible for cluster scheduling.

Why do you use zookeeper?

Zookeeper can provide configuration management, naming services, distributed algorithms, and cluster management functions. Refer to the following article for specific instructions:

Http://zhidao.baidu.com/question/919262980452730419.html?fr=iks&word=zookeeper+dubbo+%B9%D8%CF%B5&ie= Gbk

Zookeeper installation

See next blog post

Consumer directory Structure

Create a MAVEN project Dubboclient with Eclipse, with the following structure:

Integrated Spring

Applicationcontext.xml:

Http://files.cnblogs.com/files/belen/applicationContext.xml

Invocation mode

After injecting spring, the service method is called through ApplicationContext to obtain the corresponding service interface.

Provider Directory Structure

Create a MAVEN project Dubboserver with Eclipse, with the following structure:

Integrated Spring

Applicationcontext.xml:

Http://files.cnblogs.com/files/belen/applicationProvider.xml

Start method

Classpathxmlapplicationcontext context = new Classpathxmlapplicationcontext (

New string[] {"Applicationprovider.xml"});

Context.start ();

Instance boot order

1, start zookeeper, see next blog post

Http://www.cnblogs.com/belen/articles/4804063.html

2. Start Consumer

is the application context in which spring is initialized.

3. Client Invoke Service

Dubbo Pseudo-Cluster (single zookeeper)

A standalone server simulates a Dubbo cluster and starts multiple services by running the main function multiple times. This instance will start three servers. To differentiate which service the client is calling, make a distinction between the service interface return value:

Service 1 back to Hello1 Tom

Service 2 back to Hello2 Tom

Service 3 back to Hello3 Tom

The other three services also make adjustments to externally exposed ports (Spring config file):

1 ports for service: 2090

2 Ports for service: 2089

3 Ports for service: 2088

The client randomly invokes the service interface 10 times, outputting the following result:

The service 1 is stopped and the client randomly invokes the service interface 10 times, outputting the following result:

The output results show that the Dubbo cluster has load balancing and disaster recovery function (failover). This also formally zookeeper the cluster Management services provided.

Dubbo Console

The contents of the above look less intuitive. It would be great if there was a console to manage and show. I have to say Dubbo is very intimate.

Download

Website:

Http://code.alibabatech.com/mvn/releases/com/alibaba/dubbo-admin/2.4.1/dubbo-admin-2.4.1.war

However, the address has not been downloaded recently.

http://download.csdn.net/detail/liweifengwf/7784901 can be downloaded here.

Installation

Copy the war package to the Tomcat/webapps directory and start Tomcat. In the browser, enter:

http://localhost:8080/dubbo/

Default user name and password: root,root. You can modify the user name and password by/web-inf/dubbo.properties.

Dubbo Introduction Example (ii)

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.