java version b2b2c electricity providers distributed micro social service -Spring Cloud Commons ordinary abstract

Such service discovery, circuit breakers, and load-balancing mode for all Spring Cloud Client may be independently implemented in a common abstraction layer (e.g., Eureka found or Consul) consumption.

@EnableDiscoveryClient
Commons provides @EnableDiscoveryClient comments. Find this realization DiscoveryClient interface by META-INF / spring.factories. Discovery Client implementation will add a class spring.factories disposed under org.springframework.cloud.client.discovery.EnableDiscoveryClient key. Examples DiscoveryClient realize that Spring Cloud Netflix Eureka, Spring Cloud Consul Spring Cloud Zookeeper discovery and discovery.

By default, the realization DiscoveryClient will find using remote servers automatically register the local Spring Boot server. This feature can be disabled by setting the @EnableDiscoveryClient in autoRegister = false.

ServiceRegistry
Commons now provides a ServiceRegistry interface, which provides methods such as register (Registration) and deregister (Registration) and the like, allows you to provide a customized registration services. Registration is a marker interface.

@Configuration
@EnableDiscoveryClient(autoRegister=false)
public class MyConfiguration {
    private ServiceRegistry registry;
 
    public MyConfiguration(ServiceRegistry registry) {
        this.registry = registry;
    }
 
    // called via some external process, such as an event or a custom actuator endpoint
    public void register() {
        Registration registration = constructRegistration();
        this.registry.register(registration);
    }
}

Each has its own Registry ServiceRegistry achieve realization.

Automatic registration services

By default, ServiceRegistry implementation will automatically register the service is running. To disable this behavior, there are two ways. You can set @EnableDiscoveryClient (autoRegister = false) permanently disable the automatic registration. You can also set spring.cloud.service-registry.auto-registration.enabled = false to disable this behavior by configuring.

Service endpoints registered to perform

Commons provided / service-registry actuator endpoint. The endpoint depends on the application context Spring Registration bean. By GET call / service-registry / instance-status will return to the state of Registration. POST have the same endpoint String body will change the current state of Registration for the new value. Refer to the documentation ServiceRegistry realize that you're using to get the update status of allowed values and get the value for the state.
Social e-commerce platform source code, please add penguin beg: three five San Lu wantonly II qi II five Jiu

Guess you like

Origin www.cnblogs.com/itcode-code/p/11223976.html