Browse Source

Create the gRPC worker event loop group eagerly as a final field

pull/16026/head
Nikita Mazurenko 3 weeks ago
parent
commit
f92065693c
  1. 9
      common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java

9
common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java

@ -93,7 +93,7 @@ public class EdgeGrpcClient implements EdgeRpcClient {
private ManagedChannel channel;
private EventLoopGroup workerGroup;
private final EventLoopGroup workerGroup = createWorkerGroup();
private StreamObserver<RequestMsg> inputStream;
@ -109,9 +109,6 @@ public class EdgeGrpcClient implements EdgeRpcClient {
Consumer<DownlinkMsg> onDownlink,
Consumer<Exception> onError) {
connected = false;
if (workerGroup == null) {
workerGroup = createWorkerGroup();
}
NettyChannelBuilder builder = NettyChannelBuilder.forAddress(rpcHost, rpcPort)
.eventLoopGroup(workerGroup)
.channelType(channelType())
@ -176,9 +173,7 @@ public class EdgeGrpcClient implements EdgeRpcClient {
@PreDestroy
public void destroy() {
if (workerGroup != null) {
workerGroup.shutdownGracefully();
}
workerGroup.shutdownGracefully();
}
private StreamObserver<ResponseMsg> initOutputStream(String edgeKey,

Loading…
Cancel
Save