private void heartbeatInternal(final AbstractSubscriptionConsumer consumer) {
    for (final AbstractSubscriptionProvider provider : getAllProviders()) {
      try {
        final PipeSubscribeHeartbeatResp resp = provider.heartbeat();
        // update subscribed topics
        consumer.subscribedTopics = resp.getTopics();
        // unsubscribe completed topics
        for (final String topicName : resp.getTopicNamesToUnsubscribe()) {
          LOGGER.info(
              "Termination occurred when SubscriptionConsumer {} polling topics, unsubscribe topic {} automatically",
              consumer.coreReportMessage(),
              topicName);
          consumer.unsubscribe(topicName);
        }
        provider.setAvailable();
      } catch (final Exception e) {
        LOGGER.warn(
            "{} failed to sending heartbeat to subscription provider {} because of {}, set subscription provider unavailable",
            consumer,
            provider,
            e,
            e);
        provider.setUnavailable();
      }
    }
  }
Caller should ensure that the method is called in the lock {@link #acquireReadLock()}.
iotdb-client/session/src/main/java/org/apache/iotdb/session/subscription/consumer/base/AbstractSubscriptionProviders.java