在使用gRPC通讯时,遇到了问题,每个方法内初始化调用后未正确关闭,导致错误出现,必须正确使用shutdown()正确关闭
ERROR i.g.i.ManagedChannelOrphanWrapper - *~*~*~ Channel ManagedChannelImpl{logId=47567, target=pubsub.googleapis.com:443} was not shutdown properly!!! ~*~*~*
Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.
java.lang.RuntimeException: ManagedChannel allocation site
at io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference.<init>
(ManagedChannelOrphanWrapper.java:93)
解决方案是在 catch 或 finally 块中使用shutdown()关闭连接。