xxxcrel commented on issue #10196:
URL: https://github.com/apache/dubbo/issues/10196#issuecomment-1162873588

   
   > 在修复应用级注册分组聚合时尝试更改过以下代码来支持泛匹配:(似乎能够成功获取正确的group并创建Invoker, 但是在rpc 
call时传到provider的attachment:group为consumer端配置的group(如"providerA,providerB"或“*”), 
而provider端getInvoker时会出现错误)
   > 
   > 
https://github.com/apache/dubbo/blob/7a33ddf93c43f9de8e45e7bc80a22a04beecf654/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java#L375-L377
   > 
   > 
   > 
https://github.com/apache/dubbo/blob/7a33ddf93c43f9de8e45e7bc80a22a04beecf654/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/MetadataInfo.java#L232-L241
   
   ```Java
       protected List<URL> getAddresses(String serviceProtocolKey, URL 
consumerURL) {
           if (serviceProtocolKey.contains("/")) {
               int groupDelimiterIndex = serviceProtocolKey.indexOf("/");
               String groupKey = serviceProtocolKey.substring(0, 
groupDelimiterIndex);
               String withoutGroupServiceKey = 
serviceProtocolKey.substring(groupDelimiterIndex);
               List<URL> urls = new ArrayList<>();
               if ("*".equals(groupKey)) {
                   for (String s : serviceUrls.keySet()) {
                       if (s.endsWith(withoutGroupServiceKey)) {
                           urls.addAll((List<URL>) serviceUrls.get(s));
                       }
                   }
               } else if (COMMA_SPLIT_PATTERN.split(groupKey).length > 1) {
                   String[] groups = groupKey.split(",");
                   for (String group : groups) {
                       if (serviceUrls.containsKey(group + 
withoutGroupServiceKey)) {
                           urls.addAll((List<URL>) serviceUrls.get(group + 
withoutGroupServiceKey));
                       }
                   }
               }
               if (!CollectionUtils.isEmpty(urls)) {
                   return urls;
               }
           }
           return (List<URL>) serviceUrls.get(serviceProtocolKey);
       }
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to