Dubbo RPC framework + springboot

RPC study notes

Remote procedure call Remote Procedure Call, which is a request for service from a remote computer through a network, without the need to understand the idea of ​​the underlying network technology.

RPC is a technology idea and not a specification or protocol, common RPC technologies and frameworks:

  • Application-level services framework: Ali Dubbo / Dubbox, Google gRPC, Sping Boot / Sping Cloud
  • Remote communication protocols: RMI, Socket, SOAP (Http XML) REST (HTTP JSON)
  • Communication Framework: MINA and Netty

Dubbo

Dubbo is a high performance, open the RPC java lightweight frame, the bottom Netty based, usually used in conjunction with Zookeeper. It provides three core capabilities:

  • Interface for Remote Method Invocation
  • Intelligent load balancing and fault tolerance
  • Self-service registration and discovery

The main core components:

  1. Remoting: network communication framework to achieve a sync-over-async message and request-response mechanism
  2. RPC call to a remote abstraction, supports load balancing, disaster recovery and clustering capabilities.
  3. Registry Services catalog framework, registration and service event for publish and subscribe services.

working principle:

  • Provider exposed service provider called "service provider"
  • Consumer remote service call party called "service consumer"
  • Registry service registration and discovery center, a directory service called "Service Registry"
  • B Monitor statistics number of calls and time of the call log service, called "service monitoring center"
  • Container service running container

Dubbo technical architecture

 

Published subscription process

  1. Start container, load, run service provider
  2. Service provider when you start, publishing services to provide their own registration in the registry
  3. Consumer services at startup in the registry subscription services they need

If you need to consider the case of failure or changed, you need to consider the following procedure

  1. Registry returns a list of service providers to consumers, if there is a change, the registry will change based on the long connection push data to the consumer.
  2. Service consumers, providers from the list of addresses, soft load balancing algorithm, choose a provider call, if the call fails, then select another call.
  3. Service consumers and providers, in memory of the cumulative number of calls and call time, time sent once per minute statistical data to the monitoring center.

In addition to dubbo also need to rely Netty and Curator dependence.

Dubbo SpringBoot

Pom-dependent reference

Dubbo jump-starter boat

Introducing zookeeper dependent com.101tec zkclient

@Service is dubbo in the notes, is to expose the service, do not choose the service spring

@component

In the spring plus a startup class open dubbo comment

@EnableDubboconfigration

@SpringbootApplication

@Reference consumption when using annotations

Need to reference

<group>io.dubbo.spring.boot</group> 

<artifactid>spring-boot-starter-dubbo</artifactid>

Spring Boot

springboot new spring is used to simplify the development process and initial set up.

 SpringBoot framework there are two important strategies: out of the box and convention over configuration. Out of the box, Outofbox, refers to the development process, by adding a dependent packages in the pom file MAVEN project, and then using the corresponding annotation instead of tedious XML configuration files to manage the life cycle of the object. This feature allows developers to work out of complex configuration and dependency management, more focus on business logic. Convention over configuration, Convention over configuration, a target structure is configured by the SpringBoot itself, add software design paradigm of the information in the structure by the developer. This feature reduces Although some flexibility, increases the complexity of positioning BUG, ​​but reduced the number of developers need to make a decision, while reducing the amount of XML configuration, and code compilation, testing, and packaging work can be automated .

 

 

Guess you like

Origin www.cnblogs.com/minzhao/p/12501210.html