Spring Cloud Commons 普通抽象
来源:互联网 发布:号码数据库 编辑:程序博客网 时间:2024/06/06 00:34
诸如服务发现,负载平衡和断路器之类的模式适用于所有Spring Cloud客户端可以独立于实现(例如通过Eureka或Consul发现)的消耗的共同抽象层。
@EnableDiscoveryClient
Commons提供@EnableDiscoveryClient
注释。这通过META-INF/spring.factories
查找DiscoveryClient
接口的实现。Discovery Client的实现将在org.springframework.cloud.client.discovery.EnableDiscoveryClient
键下的spring.factories
中添加一个配置类。DiscoveryClient
实现的示例是Spring Cloud Netflix Eureka,Spring Cloud Consul发现和Spring Cloud Zookeeper发现。
默认情况下,DiscoveryClient
的实现将使用远程发现服务器自动注册本地Spring Boot服务器。可以通过在@EnableDiscoveryClient
中设置autoRegister=false
来禁用此功能。
ServiceRegistry
Commons现在提供了一个ServiceRegistry
接口,它提供了诸如register(Registration)
和deregister(Registration)
之类的方法,允许您提供定制的注册服务。Registration
是一个标记界面。
@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); }}
每个ServiceRegistry
实现都有自己的Registry
实现。
服务部门自动注册
默认情况下,ServiceRegistry
实现将自动注册正在运行的服务。要禁用该行为,有两种方法。您可以设置@EnableDiscoveryClient(autoRegister=false)
永久禁用自动注册。您还可以设置spring.cloud.service-registry.auto-registration.enabled=false
以通过配置禁用该行为。
服务注册执行器端点
Commons提供/service-registry
致动器端点。该端点依赖于Spring应用程序上下文中的Registration
bean。通过GET调用/service-registry/instance-status
将返回Registration
的状态。具有String
主体的同一端点的POST将将当前Registration
的状态更改为新值。请参阅您正在使用的ServiceRegistry
实现的文档,以获取更新状态的允许值和为状态获取的值。
从现在开始,我这边会将近期研发的springcloud微服务云架构的搭建过程和精髓记录下来,帮助更多有兴趣研发spring cloud框架的朋友,希望可以帮助更多的好学者。大家来一起探讨spring cloud架构的搭建过程及如何运用于企业项目。源码来源
- Spring Cloud Commons 普通抽象
- Spring Cloud Commons 普通抽象
- Spring Cloud
- Spring Cloud
- Spring Cloud
- Spring Cloud
- Spring cloud
- spring Cloud
- Spring cloud
- spring cloud
- spring cloud
- spring cloud
- Spring Cloud
- Spring cloud
- spring cloud
- Spring Cloud
- Spring Cloud
- spring cloud
- 成为 Android 大牛的10大独门秘籍
- springboot(五):spring data jpa的使用
- AndroidStudio3.0最新 Android Profiler分析器(cpu memory network 分析器)
- 函数的调用过程,栈帧的创建与销毁
- LOJ6004 「网络流 24 题
- Spring Cloud Commons 普通抽象
- Angular练习之animations动画
- android圆形进度条
- 父类引用调用子类对象
- springboot(六):如何优雅的使用mybatis
- postgresql 不阻塞创建索引
- C++基于对象--Class without pointer
- USB设备请求
- Road of poj-1002