Skip to content

dubbo3.0.5如何使用stubevent? #9711

@xxxcrel

Description

@xxxcrel
  • I have searched the issues of this repository and believe that this is not a duplicate.

Ask your question here

我在@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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions