fanliang11 / surging

Surging is a micro-service engine that provides a lightweight, high-performance, modular RPC request pipeline. support Event-based Asynchronous Pattern and reactive programming ,The service engine supports http, TCP, WS,Grpc, Thrift,Mqtt, UDP, and DNS protocols. It uses ZooKeeper and Consul as a registry, and integrates it. Hash, random, polling, Fair Polling as a load balancing algorithm, built-in service governance to ensure reliable RPC communication, the engine contains Diagnostic, link tracking for protocol and middleware calls, and integration SkyWalking Distributed APM
MIT License
3.24k stars 923 forks source link

MqttRemoteInvokeService 在创建transportClient 和使用transportClient之后,是否应该立即关闭该transportClient? #395

Closed karqical2016 closed 4 years ago

karqical2016 commented 4 years ago

Surging.Core.Protocol.Mqtt.Internal.Runtime.Implementation.MqttRemoteInvokeService 中 的方法InvokeAsync(RemoteInvokeContext context, CancellationToken cancellationToken)内部,在创建transportClient 和使用transportClient之后,是否应该立即关闭该transportClient?

foreach (var address in addresses) { try { var endPoint = address.CreateEndPoint(); if (_logger.IsEnabled(LogLevel.Debug)) _logger.LogDebug($"使用地址:'{endPoint}'进行调用。"); var client =await _transportClientFactory.CreateClientAsync(endPoint); await client.SendAsync(invokeMessage, cancellationToken).WithCancellation(cancellationToken); } catch (CommunicationException) { await _healthCheckService.MarkFailure(address); } catch (Exception exception) { _logger.LogError(exception, $"发起请求中发生了错误,服务Id:{invokeMessage.ServiceId}。"); } }

是否应该对client 进行Dispose 资源释放