服务降级
![]() | 2.2.0以上版本支持 |
![]() | 参见:配置规则 |
向注册中心写入动态配置覆盖规则:(通过由监控中心或治理中心的页面完成)
RegistryFactory registryFactory = ExtensionLoader.getExtensionLoader(RegistryFactory. class ).getAdaptiveExtension(); Registry registry = registryFactory.getRegistry(URL.valueOf( "zookeeper://10.20.153.10:2181" )); registry.register(URL.valueOf( "override://0.0.0.0/com.foo.BarService?category=configurators&dynamic=false&application=foo&mock=force:return+null" )); |
其中:
mock=force: return + null |
- 表示消费方对该服务的方法调用都直接返回null值,不发起远程调用。
- 屏蔽不重要服务不可用时对调用方的影响。
还可以改为:
mock=fail: return + null |
- 表示消费方对该服务的方法调用在失败后,再返回null值,不抛异常。
- 容忍不重要服务不稳定时对调用方的影响。
Labels:
None
3 Comments
comments.show.hide八月 29, 2012
Anonymous
Aprpiceation for this information is over 9000-thank you!
八月 31, 2012
Anonymous
9VobAE , [url=http://fpwafunoufcd.com/]fpwafunoufcd[/url], [link=http://spafuyhfroho.com/]spafuyhfroho[/link], http://odlasegwumyk.com/
十一月 15, 2013
Anonymous
降级后的服务 在服务恢复后,调用方怎么恢复使用呢?