Spring Cloud Commons General abstraction

Source: Internet
Author: User

Patterns such as service discovery, load balancing, and circuit breakers apply to the common abstraction layer that all spring cloud clients can consume independently of implementations (for example, through Eureka or consul Discovery).

@EnableDiscoveryClient

Commons provides @enablediscoveryclient annotations. This finds the implementation of the Discoveryclient interface through Meta-inf/spring.factories. Discovery The implementation of the client will add a configuration class in the spring.factories under the Org.springframework.cloud.client.discovery.EnableDiscoveryClient key. Examples of discoveryclient implementations are spring cloud Netflix eureka,spring Cloud Consul Discovery and Spring Cloud zookeeper discovery.

By default, the implementation of Discoveryclient will automatically register the local spring boot server with the remote discovery server. You can disable this feature by setting Autoregister=false in @enablediscoveryclient.

Serviceregistry

Commons now provides a serviceregistry interface that provides methods such as register (registration) and deregister (registration) that allow you to provide custom registration services. Registration is a markup interface.

@Configurationbr/> @EnableDiscoveryClient (autoregister=false)

Private Serviceregistry Registry;

public MyConfiguration(ServiceRegistry registry) {    this.registry = registry;}// called via some external process, such as an event or a custom actuator endpointpublic void register() {    Registration registration = constructRegistration();    this.registry.register(registration);}

}
Each serviceregistry implementation has its own registry implementation.

Spring Cloud Commons General abstraction

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.