About Spring Cloud Eureka

Source: Internet
Author: User

first, let's try using spring Cloud Eureka to implement service governance.  
Spring Cloud Eureka is the Service governance module under the spring Cloud Netflix project. The spring cloud Netflix project is one of Spring cloud's sub-projects, primarily packaged with Netflix's range of open source products, which provides a self-configuring Netflix OSS integration for spring boot applications. With some simple annotations, developers can quickly configure common modules in the application and build large, distributed systems. It mainly provides modules including: Service Discovery (Eureka), Circuit breakers (Hystrix), intelligent routing (Zuul), Client load Balancing (Ribbon), etc.  
Here's a look at how to implement service governance with spring Cloud Eureka.  


Create a service registration center 

Create a basic spring boot project, named Eureka-server, and introduce the required dependencies in the Pom.xml:Start a service registry with @enableeurekaserver annotations to provide conversations to other apps. This step is very simple, just add this annotation to a normal spring boot application to enable this feature, such as the following example: 
By default, the service registry will also attempt to register itself as a client, so we need to disable its client registration behavior by simply adding the following information to the Application.properties configuration file: 
to differentiate the service from subsequent registrations, the port for the service registry is set to 1001 via the Server.port property.  
650) this.width=650; "class=" j_post_img j_lazy "src=" http://blog.didispace.com/content/images/posts/ Spring-cloud-starter-dalston-1-1.png "border=" 0 "style=" Border:0px;vertical-align:top;background:rgb (247,247,247 ); "alt=" Spring-cloud-starter-dalston-1-1.png "/>


Create a "service provider" 

below we create the client that provides the service, and register ourselves with the Service registration center. In this article we mainly introduce the registration and discovery of services, so we may try to provide an interface in the service provider to obtain all the current service information.  
first, create a basic spring boot app. Named Eureka-client, in Pom.xml, add the following configuration:
Second, the implementation of the/DC request processing interface, through the Discoveryclient object, in the log to print out the relevant content of the service instance.  
Finally, by adding @enablediscoveryclient annotations to the main class, this annotation activates the discoveryclient implementation in the Eureka so that the output of the service information in the controller can be realized.
[table=100%, #ffffff,, 1,MIDDLE][TR][TD]with the Spring.application.name property, we can specify that the name of the microservices will follow the call and only use that name to access the service. The Eureka.client.serviceUrl.defaultZone property corresponds to the configuration content of the service registry, specifying the location of the service registry. In order to test differentiated service providers and service registries on this computer, use the Server.port property to set different ports. [/TD][TD]
[/td][/tr][/table]650) this.width=650; "class=" j_post_img j_lazy "src=" http://blog.didispace.com/content/images/posts/ Spring-cloud-starter-dalston-1-2.png "border=" 0 "style=" Border:0px;vertical-align:top;background:rgb (247,247,247 ); "alt=" Spring-cloud-starter-dalston-1-2.png "/>
of course, we can also get the current list of services by directly accessing the/DC interface provided by the Eureka-client service 
among these, the eureka-client in square brackets is the list of all services that are obtained in the implementation of Eureka through the Discoveryclient interface defined by spring cloud. Since spring cloud has done a very good job of abstraction in the service discovery layer, for the above program, we can seamlessly switch from Eureka's service governance system to Consul's service governance system Central.  
< Span id= "j_att_3420" >
from now on, my side will be the recently developed springcloud The process and essence of the micro-service cloud architecture is recorded to help more interested in developing Frame of friends, > hope to help more good scholars. Let's explore spring cloud structure of the construction process and how to apply to enterprise projects. SOURCE

About Spring Cloud Eureka

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.