Service registration for Eureka in Spring Cloud

Source: Internet
Author: User

The service registration in Eureka is divided into service registration center, and service registration.

One, service registrant

The service registrant registers itself on the Eureka server when it is started by sending a rest request. Eureka server stores the original information of the service registration on a double-layered map, the first key is the service name, and the second tier key is the specific service instance name.

After the registration is complete, the service provider will maintain a heartbeat to persist, calling the renewal service interval through Eureka. Instance.less-renewal-interval-in-seconds to set the default is 30 seconds.

To turn on the provider of the service, we configure it via @enablediscoveryclient.

Its main role is to open an example of a discoveryclient

/**

* Annotation to enable a discoveryclient implementation.

* @author Spencer Gibb

*/

In the Eureka implementation of the service governance corresponds to the implementation of eurekadiscoveryclient, specifically through the implementation of Eurekaclient is discoveryclient to complete.

Second, the registration center.

The registry accepts and processes requests from service registrants, and the logic for processing registration requests is in Applicationresource's Addinstance method.

After the checksum is completed, registration is done through the Regist method in Instanceregistry.

public void Register (instanceinfo info, int leaseduration, Boolean isreplication) {

Handleregistration (info, leaseduration, isreplication);

Super.register (info, leaseduration, isreplication);

}

private void Handleregistration (instanceinfo info, int leaseduration,

Boolean isreplication) {

Log ("register" + info.getappname () + ", VIP" + info.getvipaddress ()

+ ", leaseduration" + Leaseduration + ", isreplication"

+ isreplication);

Publishevent (New Eurekainstanceregisteredevent (this, info, leaseduration,

isreplication));

}

In the Handleregistration method, broadcast the event registered by the service.

The parent class's method is then called to complete the registration.

Service registration for Eureka in Spring Cloud

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.