Eureka Quick Start

Eureka Quick Start

remote call problem

Multiple services have multiple ports, so there are multiple services, hard coding is not suitable

insert image description here

The role of eureKa

  • Record all the service ports of the service. If you want, query directly from the registration center.
  • For all services, you need to send a request to eureKa every once in a while to ensure that the service is still alive

insert image description here

insert image description here

Hands

Build eureKa registration center

insert image description here

Three steps:

  • Introduce server-side dependencies
  • add annotation
  • configuration

register user-service

Register the service service to the eureka service, the same as the order service

  • two steps
  • Introduce dependencies
  • Add client configuration and remember to pay attention to the name of the service

insert image description here

in conclusion:

  • Introduce eureka-client dependency
  • Configure eureka address in applicatin.yml

Complete service pull in order-service

 Service pull is to obtain the service list based on the service name, and then perform load balancing on the service list

insert image description here

  • Introduce eureka-client dependency
  • Configure the eureka address in application.yml
  • Add the @LoadBalanced annotation to restTemplate because there are multiple services adding this annotation can dynamically select services to achieve load balancing
  • Remote call with the service name of the service provider

Guess you like

Origin blog.csdn.net/qq_44653420/article/details/132428743