Uploaded image for project: 'Apache RocketMQ'
  1. Apache RocketMQ
  2. ROCKETMQ-242

mqclient can not fetch nameSrvAddr periodly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.0.0-incubating, 4.1.0-incubating
    • Fix Version/s: 4.2.0
    • Component/s: rocketmq-client
    • Labels:
      None
    • Environment:
      test and production

      Description

      when mqclientinstance start, it getNameSrvAddr once by bellow code:
      if (null == this.clientConfig.getNamesrvAddr())

      { this.clientConfig.setNamesrvAddr(this.mQClientAPIImpl.fetchNameServerAddr()); }

      but in startScheduledTask()´╝îit will not start the schedule task if namesrvAddr is not null

      ================code=====================

      
      

      public void start() throws MQClientException {

      synchronized (this) {
      switch (this.serviceState) {
      case CREATE_JUST:
      this.serviceState = ServiceState.START_FAILED;
      // If not specified,looking address from name server
      * if (null == this.clientConfig.getNamesrvAddr()) { this.clientConfig.setNamesrvAddr(this.mQClientAPIImpl.fetchNameServerAddr()); }

      *
      // Start request-response channel
      this.mQClientAPIImpl.start();
      // Start various schedule tasks
      this.startScheduledTask();
      // Start pull service
      this.pullMessageService.start();
      // Start rebalance service
      this.rebalanceService.start();
      // Start push service
      this.defaultMQProducer.getDefaultMQProducerImpl().start(false);
      log.info("the client factory [{}] start OK", this.clientId);
      this.serviceState = ServiceState.RUNNING;
      break;
      case RUNNING:
      break;
      case SHUTDOWN_ALREADY:
      break;
      case START_FAILED:
      throw new MQClientException("The Factory object[" + this.getClientId() + "] has been created before, and failed.", null);
      default:
      break;
      }
      }
      }

      private void startScheduledTask() {
      * if (null == this.clientConfig.getNamesrvAddr()) {
      *
      this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {

      @Override
      public void run() {
      try

      { MQClientInstance.this.mQClientAPIImpl.fetchNameServerAddr(); }

      catch (Exception e)

      { log.error("ScheduledTask fetchNameServerAddr exception", e); }

      }
      }, 1000 * 10, 1000 * 60 * 2, TimeUnit.MILLISECONDS);
      }

      
      

        Attachments

          Activity

            People

            • Assignee:
              vintagewang Xiaorui Wang
              Reporter:
              easonchen Eason Chen
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: