In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the example analysis of the application design of SpringCloud basic components in the micro-service architecture, which has a certain reference value. Interested friends can refer to it. I hope you will learn a lot after reading this article.
1. Component application planning
1. Registration center
Eureka component is developed by Netflix, which is used to locate services and realize service registration and discovery based on RESTFul. It includes an EurekaServer server (usually a registry in a microservice) and an EurekaClient client (usually a business service in a microservice). Eureka supports highly available configurations. When the registry finds a faulty service, Eureka will switch to automatic protection mode. The failure does not affect the discovery and registration of the service. When the failure returns to normal, the registry service will synchronize the status and continue to provide services.
2. Service call
The Feign component is a declarative WebService client. In the services registered by Eureka, the Feign interface can be used to call requests between related services, and provide the related features of timeout fallback and fast circuit breaker. Feign is a convenient RestFul framework, which simplifies the call, finds the service instance in the registration server through ribbon, and then allocates the service to the request, which achieves the effect of load balancing. The polling algorithm is used by default.
3. Service Gateway
The GateWay gateway allows all client requests to interact with the gateway through the micro-service gateway, and the gateway forwards requests for various micro-services. The client (front end) is not aware of the multi-service architecture. Reduce the interactive coupling between the client and the micro-service; facilitate monitoring and monitor data in the gateway; uniformly handle authentication at the gateway layer and plan aspect programming; that is to say, common logic independent of the function of the business itself can be uniformly encapsulated and implemented at the gateway layer, similar to the facade pattern in the design pattern.
II. Registration centre
1. The server configures eureka: server: enable-self-preservation: false eviction-interval-timer-in-ms: 15000 instance: prefer-ip-address: true client: register-with-eureka: false fetch-registry: false service-url: defaultZone: http://127.0.0.1:5001/eureka/2, Client configuration eureka: instance: prefer-ip-address: true client: service-url: defaultZone: http://127.0.0.1:5001/eureka/ 3, Feign component 1, Feign interface @ FeignClient ("MOPSZ-SOFT-ROCKET") public interface UserSearchFeign {@ GetMapping ("/ mq/user/search/sendBookSearch") void sendBookSearch (@ RequestParam ("msgContent") String msgContent) } 2. Feign interface implementation @ RestControllerpublic class UserSearchController implements UserSearchFeign {@ Override public void sendBookSearch (String msgContent) {}} 3, interface configuration
The configuration file can be configured in a project that implements the Feign interface, or for a specific method.
Feign: hystrix: enabled: true client: config: feignName: connectTimeout: 60000 readTimeout: 600004, Feign API call @ Resourceprivate UserSearchFeign userSearchFeign; userSearchFeign.sendBookSearch ("") 4. Service Gateway 1. The gateway component is configured with the zuul: # prefix, which can be used for version control prefix: / v1 # disable default routing Perform the configured routing ignored-services: "*" routes: # configure Token service pro6601: serviceId: mopsz-basis-token path: / api/6601/** # configure UserClient service pro6102: serviceId: mopsz-user-client path: / api/6102/**
Configure FilterConfig to intercept user Token authentication
Configure FallBackConfig for service degradation response management
2. Project deployment
After the project is launched, a gateway service port is exposed, other service ports are not exposed, and all requests must be intercepted or forwarded through the gateway. This is a common way for micro-services to provide services.
Thank you for reading this article carefully. I hope the article "sample Analysis of the Application Design of SpringCloud basic components in Micro Services Architecture" shared by the editor will be helpful to you. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.