Skip to content

a problem about "url" config in dubbo:reference #5089

@maslke

Description

@maslke

dubbo version: 2.7.3
os version: Windows 10
jdk version: 1.8

I met a problem when I learn to use the "url" config in dubbo:reference. I choose zookeeper as registry.

I have these codes in my provider.

interface GreetingService {
    String sayHello(String name);
}

class GreetingServiceImpl implements GreetingService {
    String sayHello(String name) {
        return "hello, " + name;
    }
}

I have these configs in my provider.xml

<bean id="target1" class="com.....GreetingServiceImpl" />
<bean id="target2" class="com.....GreetingServiceImpl" />

<dubbo:service interface="com....GreetingService" ref="target1" group="group1" version="2.0.0"/>
<dubbo:service interface="com...GreetingService" ref="target2" group="group2" version="2.0.0" />

Situation 1.
In this case, the consumer will work.

<dubbo:reference check="false" url="dubbo://127.0.0.1:20880?group=group1&amp;version=2.0.0"  id="mergerService" interface="com.maslke.dubbo.samples.merger.api.MergerService" group="group1" version="2.0.0" />

Situation 2.
In this case, the consumer will not work. It will throw an exception like this "Not found exported service".

<dubbo:reference check="false" url="dubbo://127.0.0.1:20880?group=group2&amp;version=2.0.0"  id="mergerService" interface="com.maslke.dubbo.samples.merger.api.MergerService" group="group2" version="2.0.0" />

Situation3.
I modify my provider.xml and add id to dubbo:service.

<bean id="target1" class="com.....GreetingServiceImpl" />
<bean id="target2" class="com.....GreetingServiceImpl" />

<dubbo:service id="greetingService" interface="com....GreetingService" ref="target1" group="group1" version="2.0.0"/>
<dubbo:service id="greetingServic2" interface="com...GreetingService" ref="target2" group="group2" version="2.0.0" />

If I do this,situation 1 and situation 2 will both work correctly.

So here is the question.

  1. Is this a bug?
  2. if this is not a bug, so id is necessary in my situation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions