50,528
社区成员
发帖
与我相关
我的任务
分享
//封装注册中心和提供者连接实例
ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>();
reference.setApplication(application);
reference.setRegistry(registry);
reference.setInterface(interfaceClass);
reference.setGroup(group);
reference.setVersion("");
reference.setGeneric(true);
reference.setAsync(true);
List<MethodConfig> methodConfigList = new ArrayList<>();
MethodConfig method = new MethodConfig();
method.setAsync(true);
method.setName(methodName);
//指定事件回调方法
method.setOnreturn("notify.onreturn");
method.setOnthrow("notify.onthrow");
methodConfigList.add(method);
reference.setMethods(methodConfigList);
//使用dubbo内置的简单缓存工具类进行缓存
ReferenceConfigCache cache = ReferenceConfigCache.getCache();
GenericService genericService = cache.get(reference);