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

SendHeartBeart log may not be triggered in the same expected period

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1.0-incubating
    • Component/s: rocketmq-client
    • Labels:
      None

      Description

          private void sendHeartbeatToAllBroker() {
              final HeartbeatData heartbeatData = this.prepareHeartbeatData();
              final boolean producerEmpty = heartbeatData.getProducerDataSet().isEmpty();
              final boolean consumerEmpty = heartbeatData.getConsumerDataSet().isEmpty();
              if (producerEmpty && consumerEmpty) {
                  log.warn("sending heartbeat, but no consumer and no producer");
                  return;
              }
      
              long times = this.storeTimesTotal.getAndIncrement();//here every time when the method is call, the times will increase even though acatully no heartbeat is sent
              Iterator<Entry<String, HashMap<Long, String>>> it = this.brokerAddrTable.entrySet().iterator();
              while (it.hasNext()) {
                  Entry<String, HashMap<Long, String>> entry = it.next();
                  String brokerName = entry.getKey();
                  HashMap<Long, String> oneTable = entry.getValue();
                  if (oneTable != null) {
                      for (Map.Entry<Long, String> entry1 : oneTable.entrySet()) {
                          Long id = entry1.getKey();
                          String addr = entry1.getValue();
                          if (addr != null) {
                              if (consumerEmpty) {
                                  if (id != MixAll.MASTER_ID)
                                      continue;
                              }
      
                              try {
                                  this.mQClientAPIImpl.sendHearbeat(addr, heartbeatData, 3000);
                                  if (times % 20 == 0) {//since the first call is times !=1, the heart beat log for the first heart beat could be missed
                                      log.info("send heart beat to broker[{} {} {}] success", brokerName, id, addr);
                                      log.info(heartbeatData.toString());
                                  }
                              } catch (Exception e) {
                                  if (this.isBrokerInNameServer(addr)) {
                                      log.error("send heart beat to broker exception", e);
                                  } else {
                                      log.info("send heart beat to broker[{} {} {}] exception, because the broker not up, forget it", brokerName,
                                          id, addr);
                                  }
                              }
                          }
                      }
                  }
              }
          }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Jaskey Jaskey Lam
                Reporter:
                Jaskey Jaskey Lam
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: