我在@DubboReference注解中看到有一项stubevent配置, 并尝试设置为true, @DubboReference(onconnect = "onConnect", stubevent = true, stub = "DemoServiceLocal") 我的本地存根类如下:
package org.apache.dubbo.demo.consumer;
import org.apache.dubbo.demo.DemoService;
public class DemoServiceLocal implements DemoService {
private DemoService demoService;
public DemoServiceLocal(DemoService demoService){
this.demoService = demoService;
}
@Override
public String sayHello(String name) {
return demoService.sayHello(name);
}
public void onConnect(){
System.out.println("DemoServiceLocal.onConnect()");
}
}
按照Provider端的onconnect, ondisconnect事件通知理解, 在Consumer端的存根也支持onconnect, ondisconnect事件 但是Consumer端抛出如下异常:
13:00:59.150 [main] ERROR org.apache.dubbo.rpc.proxy.wrapper.StubProxyFactoryWrapper - [DUBBO] export a stub service error., dubbo version: 3.0.5, current host: 192.168.40.120 java.lang.NullPointerException: null at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936) at org.apache.dubbo.rpc.support.GroupServiceKeyCache.getServiceKey(GroupServiceKeyCache.java:37) at org.apache.dubbo.rpc.support.ProtocolUtils.serviceKey(ProtocolUtils.java:51) at org.apache.dubbo.rpc.protocol.AbstractProtocol.serviceKey(AbstractProtocol.java:75) at org.apache.dubbo.rpc.protocol.AbstractProtocol.serviceKey(AbstractProtocol.java:71) at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol.export(DubboProtocol.java:296) at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:66) at org.apache.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:76) at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:61) at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.export(ProtocolSerializationWrapper.java:47) at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java) at org.apache.dubbo.rpc.proxy.wrapper.StubProxyFactoryWrapper.export(StubProxyFactoryWrapper.java:123) at org.apache.dubbo.rpc.proxy.wrapper.StubProxyFactoryWrapper.getProxy(StubProxyFactoryWrapper.java:93) at org.apache.dubbo.rpc.ProxyFactory$Adaptive.getProxy(ProxyFactory$Adaptive.java) at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:400) at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:275) at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:216) at org.apache.dubbo.config.utils.SimpleReferenceCache.get(SimpleReferenceCache.java:110) at org.apache.dubbo.config.deploy.DefaultModuleDeployer.lambda$referServices$6(DefaultModuleDeployer.java:384) at java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4707) at org.apache.dubbo.config.deploy.DefaultModuleDeployer.referServices(DefaultModuleDeployer.java:364) at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:151) at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.startModules(DefaultApplicationDeployer.java:617) at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.doStart(DefaultApplicationDeployer.java:581) at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.start(DefaultApplicationDeployer.java:554) at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:222) at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:212)
原提问者GitHub用户xxxcrel
DubboReference里的stub值要类的权限定名 class.getName()
原回答者GitHub用户BurningCN
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。