/// <summary> /// 停止 /// </summary> /// <param name="cancellationToken"></param> /// <returns></returns> public override async Task StopAsync(CancellationToken cancellationToken) { // Remove listener await _configClient.RemoveListener(OcelotConfig, OcelotConfigGroup, nacosConfigListener); await _configClient.RemoveListener(AppConfig, AppConfigGroup, AppConfigListener); await base.StopAsync(cancellationToken); }
/// <summary> /// 停止 /// </summary> /// <param name="cancellationToken"></param> /// <returns></returns> public override async Task StopAsync(CancellationToken cancellationToken) { // Remove listener await _configClient.RemoveListener("blog.Core.Api.json", "DEFAULT_GROUP", nacosConfigListener); await base.StopAsync(cancellationToken); }
static async Task ListenConfig(INacosConfigService svc, IListener listener) { var dataId = "demo-dateid"; var group = "demo-group"; // 添加监听 await svc.AddListener(dataId, group, listener); await Task.Delay(500); // 模拟配置变更,listener会收到变更信息 await PublishConfig(svc); await Task.Delay(500); await PublishConfig(svc); await Task.Delay(500); // 移除监听 await svc.RemoveListener(dataId, group, listener); // 配置变更后,listener不会收到变更信息 await PublishConfig(svc); }