dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

ApplicationModel serviceName is not unique

Open haiyang1985 opened this issue 8 years ago • 5 comments

  • [ ] 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: https://github.com/apache/incubator-dubbo/pull/2582

haiyang1985 avatar Sep 29 '18 06:09 haiyang1985

It is dependent on how do you defind a Service:

  • a backend service is a Service
  • or a proxy service is a Service

kimmking avatar Sep 30 '18 12:09 kimmking

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.

haiyang1985 avatar Oct 04 '18 02:10 haiyang1985

@haiyang1985 I drop a comment in https://github.com/apache/incubator-dubbo/pull/2582#pullrequestreview-162318577, pls. take a look.

beiwei30 avatar Oct 08 '18 02:10 beiwei30

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.

Jeff-Lv avatar Oct 24 '18 06:10 Jeff-Lv

@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 https://github.com/apache/incubator-dubbo/pull/2646.

beiwei30 avatar Oct 24 '18 06:10 beiwei30