Today’s sharing started, please give us more advice ~

What is microservices Architecture

To put it simply, microservices are a design style of system architecture that aims to break up a previously independent system into small services that run in separate processes and communicate and collaborate with each other through RESTful apis based on HTTP. Each small service is built around one or more highly coupled business in the system, and each service maintains its own data storage, business development, automated testing, and independent deployment. All of these microservices can be written in different languages thanks to a lightweight communication collaboration foundation.

SpringCloud profile

SpringCloud is a microservices framework development tool based on SpringBoot implementation. It provides a simple development approach for configuration management, service governance, circuit breakers, intelligent routing, micro proxy, distributed session and cluster state management operations involved in microservices architecture.

SpringCloud Config: a configuration management tool that can use Git to store configuration content. It can be used to externalize application configuration and refresh client configuration information.

SpringCloud Netflix: Core component that integrates multiple NetflixOSS open source suites.

Eureka: Service governance component that contains the implementation of a service registry, service registration, and discovery mechanism.

Hystrix: Fault tolerant management component that implements circuit breaker mode to help with delays in service dependencies and provide strong fault tolerance for failures.

Ribbon: Load balancing service invocation component.

Feign: A declarative service invocation component based on the Ribbon and Hystrix.

Zuul: gateway component that provides intelligent routing and access filtering functions.

SpringCloud Consul: Service discovery and configuration management tool.

SpringCloud Stream: A consumer microservice implemented through Redis, Rabbit, or Kakfa that sends and receives messages using a simple declarative model.

And so on ~ ~ ~

Eureka

Setting up a registry

Create a basic SpringBoot project, named Eureka-Server, and introduce the necessary dependencies into the POM file as follows:

Add the @enableeurekaserver annotation to the bootstrap class to start a service registry for other applications to talk to

Modify default configuration, port number, microservice name, registry address

Register service provider

Create a basic SpringBoot project, call it Eureka-Provider, and introduce the necessary dependencies into the POM file, same code as above

Add the @enableDiscoveryClient annotation to the bootstrap class to add this microservice to the registry

Modify the default Settings: port number, micro service name, registered to Eureka

Registered Service Consumers

Create a basic SpringBoot project, call it Eureka-Consumer, and introduce the necessary dependencies into the POM file, same as above

Add the @enableDiscoveryClient annotation to the bootstrap class to add this microservice to the registry

Modify the default Settings: port number, micro service name, registered to Eureka

Test: start each project,

This is all about the registry, Eureka.

Feign

Create a SpringBoot base project called Feigen-Counsumer. And introduce the necessary dependencies into the POM file

Add the @enableFeignClients annotation to the bootstrap class to enable SpringCloud Feignd support

Define the HelloService interface and bind the service by specifying the service name via the @FeignClient annotation

Create a ConsumerController to implement a call to the Feign client using @AutoWired to inject the helloService instance directly above

Modify the default Settings: port number, micro service name, registered to Eureka

Testing:

Send several GET requests Http: localhost: 9001/ Feign-consumer, correctly returning “Hello World”

Zuul

Create a SpringBoot infrastructure project called SpringCloud-Zuul. And introduce the necessary dependencies into the POM file

Add the @enableZuulProxy annotation to the bootstrap class to enable SpringCloud Zuul support

Create LoginFilter inheriting from ZuulFilter, adding the interceptor’s business code

Modify the default Settings: port number, micro service name, registered to Eureka

Test: Access through gateway — THE URL does not contain token, contains token, and opens inconsistent interfaces

Personal summary

Eureka

Registry: Eureka-Server

1. Import an initiator

2 configuration spring. Application. Name = dynamic. Eureka

3. Add @enableeurekaserver to the boot class

Client: Server-provider, server-consumer

1. Import an initiator

2 configuration spring. Application. The name, eureka. Service – url. DefaultZone = http://localhost:10086/eureka

3.@EnableDiscoveryClient (Start eureka client)

Feign

2. Add @enableFeignClients 3 to the boot class. Custom interface that binds service 4 with the @feignClient annotation specifying the service name. Changing the Default ConfigurationCopy the code

Zuul

1. Import the Zuul initiator

2. Add the @enableZuulProxy annotation to the startup class

3. Create a filter, inherit ZuulFilter base class, override the four methods

4. Configure route zuul.router. service-provider: /service-provider/**

Today’s share has ended, please forgive and give advice!