-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Nacos Discovery] Add configuration properties to decide poll or not poll the subscription service. #661
Comments
@fangjian0423
请考虑如下几点:
|
这个 issue 还在讨论阶段,所以代码层面还没有动过。 其实我觉得这个问题,只要找不到服务不要报 404 错误就可以了,服务中心专注于做自己的事,直接节点数为0,怎么处理,是上层应该关系的事情,不应该和上层的逻辑杂糅在一起。 |
@fangjian0423 不关服务中心的事情,服务不存在服务中心返回404是正常的。但是在DiscoveryClient这一端,只要调用discoveryClient的getInstances方法去获取一个不存在的服务A时,DiscoveryClient这一端就不断刷日志。原来是DiscoveryClient每隔一秒就偿试去更新这服务A的消息,所以每隔一秒就会刷一次日志,而这个定时任务是白跑的,因为服务A永远都不会存在。 |
这个 DiscoveryClient(NacosDiscoveryClient) 的 getInstances 方法调用的是 这个方法底层是调用另外一个方法,且 subscribe 属性为 true。 subscribe 属性为 true 表示是一直轮询订阅服务直到订阅到(如果服务不存在,naming.log 刷日志)。 Spring Cloud 自身是不存在定时�跑刷日志的任务的。 |
@fangjian0423 |
Which Component
Nacos Discovery
Is your feature request related to a problem? Please describe.
Now nacos discovery starter will always poll the subscription service until it can subscribe when service is not exists.
Refer the method
List<Instance> selectInstances(String serviceName, boolean healthy) throws NacosException;
ofNamingService
.We can choose the other method
List<Instance> selectInstances(String serviceName, boolean healthy, boolean subscribe) throws NacosException;
to not poll the subscription service when service is not exists.Describe the solution you'd like
Add an configuration properties
boolean subscribe;
inNacosDiscoveryProperties
to decide poll or not poll the subscription service.The text was updated successfully, but these errors were encountered: