In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
preface
With the increasing popularity of service-oriented programming, more and more companies, enterprises and developers are using microservices technology. There are two popular microservices technologies: dubbo\SpringCloud. This article will not compare dubbo and SpringCloud. In this article, I mainly want to introduce the netflix component in the SpringCloud family bucket, and explain it in combination with the actual case code. I also summarize the use of SpringCloud in my work.
NetFlix
Netflix is the name of a paid video site company, one of the top ten video sites in the world, if you want to know about it, you can Google it. Spring Cloud Netflix is a component library in Spring Cloud that provides Netflix OSS integration for Spring Boot applications by automatically configuring and binding to Spring environments and other Spring programming model idioms. With a few simple annotations, common patterns within an application can be quickly enabled and configured, and Netflix components build large distributed systems. Offers include service discovery (Eureka), fuses (Hystrix), intelligent routing (Zuul), and client Load Balancer (Ribbon).
Service Discovery (Eureka)
Service discovery (Eureka) is the core component of Netflix, responsible for service registration and managing service lists. The following diagram explains Eureka's responsibilities:
All services need to be registered on Eureka-Server. Order service, product service, payment service and user service are all services managed by Eureka. They need to be reported. The information reported includes ServiceId, node address, service interface, etc. Then the registration center will maintain this service list through heartbeat check. Next we write an Eureka-Server, Product-Service to simulate this service discovery.
Development environment and tools: IDEA+JDK8+SpringBoot2.1.0
At this point, the project is created, but at this time it is only a SpringBoot project and needs to open the EurekaServer annotation.
At the same time, let's configure application.yml:
We launch the project and open the admin console with a browser.
At this point, we have finished writing EurekaServer, so we are going to write Product-Service.
Before writing, we first determine the interface provided. The list interface provides all product information, and the find interface searches for product information according to id. Product-Service, we write Controller, Service and Domain according to the general mode, and the process is as follows:
Commodity domain class, including id, name, price, inventory.
We also need to configure application.yml so that this service can be automatically registered with Eureka-Server.
We start the Product-service. We started three instances of Product-Service 8771\8772\8773, and then we went to Eureka-Server.
At this time, we can see that Product-Service service has been automatically registered here. There are three nodes in total, and the ports are 8771, 8772, and 8773 respectively.
interfaces can also be used.
We can stop one of these nodes: 8773, and look at Eureka Server.
We found that 8773 product-service on eurekaserver shows DOWN in red font, indicating that it can check the status of the service. We started it here and you will find that down disappears.
Remarks: @EnableEurekaClient annotation can not be written, because we SPRING INITIALIZR project IDE has helped us do a lot of work, reflected in spring-cloud-starter-netflix-eureka-client, it will automatically check the application.yml, we have configured the Eureka client in the configuration file corresponding information, then this application will automatically add @EnableEurekaClient.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.