owen200008 commented on issue #8895:
URL: https://github.com/apache/dubbo/issues/8895#issuecomment-925761201
@Slf4j
public static class CommuLink {
private ReferenceConfig<DubboVersionFacade> reference = null;
@Getter
private DubboVersionFacade uChannelInstance = null;
public boolean init() {
//需要初始化
this.reference = new ReferenceConfig<>();
reference.setRegistryIds("nacos-registry");
reference.setInterface(DubboVersionFacade.class);
reference.setVersion("1.0.0");
reference.setGroup("main");
//这边是纯异步处理
// reference.setAsync(true);
reference.setCheck(false);
reference.setConnections(5);
try{
this.uChannelInstance = reference.get();
return true;
}catch(Exception e){
BasicLogUtil.errorFormat(log, "reference get error", e);
}
return false;
}
public void close() {
// reference.destroy();
try {
Method getInvoker =
ReferenceConfig.class.getDeclaredMethod("getInvoker");
getInvoker.setAccessible(true);
Invoker<?> invoker = (Invoker<?>)
getInvoker.invoke(reference);
invoker.destroyAll();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
@Test
public void checkDubboReference() throws InterruptedException {
CommuLink lastLink = null;
for(int i = 0;i < 10;i++){
if(lastLink != null){
lastLink.close();
}
CommuLink commuLink = new CommuLink();
commuLink.init();
lastLink = commuLink;
Thread.sleep(10000);
System.out.println(i);
}
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]