Skip to content

ApplicationModel serviceName is not unique #2583

Closed

Description

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

Environment

  • Dubbo version: all
  • Operating System version: all
  • Java version: all

Steps to reproduce this issue

  1. create two ReferenceConfig for same service with different configuration.
    <dubbo:reference id="demoService" interface="com.alibaba.dubbo.DemoService">
    </dubbo:reference>
    <dubbo:reference id="demoServiceAsync" interface="com.alibaba.dubbo.DemoService" async="true">
    </dubbo:reference>
  2. startup the consumer application.
  3. get the ConsumerModel from ApplicationModel.

Pls. provide [GitHub address] to reproduce this issue.

Expected Result

ApplicationModel.allConsumerModels() should returns two ConsumerModel.

Actual Result

ApplicationModel.allConsumerModels() only returns the first ConsumerModel.

If there is an exception, please attach the exception trace:

With future investigation, ReferenceConfig cannot put the second ConsumerModel as they are in same serviceName.

Also, this is the same issue for provider with below configuration.

<dubbo:service interface="com.alibaba.dubbo.DemoService" ref="demoService">
</dubbo:service>

<dubbo:service interface="com.alibaba.dubbo.DemoService" ref="demoService2">
</dubbo:service>

Here is my PR: #2582

Activity

  1. kimmking commented on Sep 30, 2018

    @kimmking
    Member

    It is dependent on how do you defind a Service:

    • a backend service is a Service
    • or a proxy service is a Service
  2. haiyang1985 commented on Oct 4, 2018

    @haiyang1985
    MemberAuthor

    Yes.
    The flexibility of refer a service with different proxy is good(As above, one proxy in sync, another in async). But, it's terrible that we are not able to get the proxy we have created.
    For that, we are able to cache the proxy by extend the ProxyFactory. But, the issue is that the wrapper executed without order, which result in different proxy returned.
    Hopefully, the constrains be removed from the ApplicationModel cache.

  3. beiwei30 commented on Oct 8, 2018

    @beiwei30
    Member

    @haiyang1985 I drop a comment in #2582 (review), pls. take a look.

  4. added a commit that references this issue on Oct 9, 2018
  5. Jeff-Lv commented on Oct 24, 2018

    @Jeff-Lv
    Contributor

    I don't think this is a problem or fixing bug. Here are two reasions.

    1. Pratically, the same service is not recommended to create twice on the consumer side. If async and sync are both needed, we can do it in mehod level to config, or a util method to switch between aync and sync.

    2. most importantly, please check the two classes (URL and StringUtils), there is a method named getServiceKey, which is used commonly in Dubbo. A service can be unique under three properties whare are serviceInterface, Group, Version. So, there is no property Ref to constraint service's unique.

    For example, a group rule or route rule is defined in ZK, which service is it applied to? I think, serviceKey (name, group, version) is the condition. So as the online/offline rules.

  6. beiwei30 commented on Oct 24, 2018

    @beiwei30
    Member

    @Jeff-Lv I agree with your opinion. For this particular problem, let's consider it as a limitation. User cannot configure two references with the different behavior. We will provide alternative way to user to change the behavior either via API, utilities or dynamic config.

    Let's roll back the relevant change in #2646.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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