dubbo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] GodIsDevil opened a new issue #2546: Consumer Node Not destroy
Date Fri, 21 Sep 2018 11:03:55 GMT
GodIsDevil opened a new issue #2546: Consumer Node Not destroy
URL: https://github.com/apache/incubator-dubbo/issues/2546
 
 
   - [x] I have searched the [issues](https://github.com/apache/incubator-dubbo/issues) of
this repository and believe that this is not a duplicate.
   - [x] I have checked the [FAQ](https://github.com/apache/incubator-dubbo/blob/master/FAQ.md)
of this repository and believe that this is not a duplicate.
   
   ### Environment
   
   * Dubbo version: 2.6.3
   * Operating System version: mac
   * Java version: 1.8
   * Registry: zookeeper
   ### Steps to reproduce this issue
   
   1. use ReferenceConfig to get a service proxy
   2. destroy ReferenceConfig
   3. consumer node in Zookeeper has not been destroyed.
   
   ### Cause
   1、When ReferenceProtocol refer an invoker, the consumer node is first registered and
then subscribed to the resources of the relevant provider in most cases.
   
   ```
   
   private <T> Invoker<T> doRefer(Cluster cluster, Registry registry, Class<T>
type, URL url) {
           RegistryDirectory<T> directory = new RegistryDirectory<T>(type, url);
           directory.setRegistry(registry);
           directory.setProtocol(protocol);
           // all attributes of REFER_KEY
           Map<String, String> parameters = new HashMap<String, String>(directory.getUrl().getParameters());
           URL subscribeUrl = new URL(Constants.CONSUMER_PROTOCOL, parameters.remove(Constants.REGISTER_IP_KEY),
0, type.getName(), parameters);
           if (!Constants.ANY_VALUE.equals(url.getServiceInterface())
                   && url.getParameter(Constants.REGISTER_KEY, true)) {
               registry.register(subscribeUrl.addParameters(Constants.CATEGORY_KEY, Constants.CONSUMERS_CATEGORY,
                       Constants.CHECK_KEY, String.valueOf(false)));
           }
           directory.subscribe(subscribeUrl.addParameter(Constants.CATEGORY_KEY,
                   Constants.PROVIDERS_CATEGORY
                           + "," + Constants.CONFIGURATORS_CATEGORY
                           + "," + Constants.ROUTERS_CATEGORY));
   
           Invoker invoker = cluster.join(directory);
           ProviderConsumerRegTable.registerConsumer(invoker, url, subscribeUrl, directory);
           return invoker;
       }
   
   ```
   
   2、When ReferenceConfig is in destroy,  it only cancels subscription to related resources,
but not to 
   remove the consumer node.
   
   ```
   
   @Override
       public void destroy() {
           if (isDestroyed()) {
               return;
           }
           // unsubscribe.
           try {
               if (getConsumerUrl() != null && registry != null && registry.isAvailable())
{
                   registry.unsubscribe(getConsumerUrl(), this);
               }
           } catch (Throwable t) {
               logger.warn("unexpected error when unsubscribe service " + serviceKey + "from
registry" + registry.getUrl(), t);
           }
           super.destroy(); // must be executed after unsubscribing
           try {
               destroyAllInvokers();
           } catch (Throwable t) {
               logger.warn("Failed to destroy service " + serviceKey, t);
           }
       }
   
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Mime
View raw message