gpt4 book ai didi

java - 以编程方式从 Eureka Server 中删除已注册的实例

转载 作者:行者123 更新时间:2023-11-30 02:40:37 25 4
gpt4 key购买 nike

有没有一种方法可以在不使用 REST 操作的情况下从 Eureka Server 中删除已注册的实例?包含所有应用程序的数据结构是什么?

(很明显,我想删除它们在 Eureka 服务器中编写代码)。

最佳答案

您需要的功能可以通过 InstanceRegistry 获得。 ,它本身只是 Netflix Eureka 类的扩展( PeerAwareInstanceRegistryImplAbstractInstanceRegistry )。

具体来说,AbstractInstanceRegistry#cancel(String,String,boolean) 方法应从注册表中删除应用程序。

此方法的 Javadoc 指出:

/**
* Cancels the registration of an instance.
*
* <p>
* This is normally invoked by a client when it shuts down informing the
* server to remove the instance from traffic.
* </p>
*
* @param appName the application name of the application.
* @param id the unique identifier of the instance.
* @param isReplication true if this is a replication event from other nodes, false
* otherwise.
* @return true if the instance was removed from the {@link AbstractInstanceRegistry} successfully, false otherwise.
*/

这就是您从 Eureka 服务器本身实现此目的的方法。

关于java - 以编程方式从 Eureka Server 中删除已注册的实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41848113/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com