Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
Consumer {
   /**
     * Alert the consumer to trigger a new rebalance by rejoining the group. You should not need to call this during
     * normal processing, as the consumer group will manage itself automatically and rebalance when necessary. However
     * there may be situations where the application wishes to trigger a rebalance that would otherwise not occur, for
     * example if some condition has changed that has implications for the partition assignment.
     * <p>
     * If a rebalance is already in progress, an exception will be thrown so you can choose to retry or not once the
     * current rebalance completes.
     *
     * @param timeout The maximum amount of time to wait for the rebalance
     *
     * @return Whether the rebalance completed within the given timeout.
     * @throws java.lang.IllegalStateException if the consumer does not use group subscription
     * @throws org.apache.kafka.common.errors.RebalanceInProgressException if a rebalance is already in progress
     * @throws org.apache.kafka.common.errors.CoordinatorNotAvailableException if the coordinator is unknown/unavailable
     * @throws org.apache.kafka.common.KafkaException if the rebalance callback throws an exception
     */
    boolean enforceRebalance(Duration timeout) {
}

...

The coordinator is unknown/unavailable

In this case we will just throw a CoordinatorNotAvailableException, so the user can retry (or not).If we cannot connect to the coordinator within the timeout, this method will just return false. It will already have marked the consumer as needing to rejoin, so the rebalance will be triggered on the next poll (or next `enforceRebalance` if retried)

Compatibility, Deprecation, and Migration Plan

...