Versions Compared

Key

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

Table of Contents

Status

Current state: "Under Discussion" Accepted

Discussion thread: here

JIRA: here

...

The reason is added as an argument to removeMembersFromConsumerGroup optional attribute to RemoveMembersFromConsumerGroupOptions class which is used by the Admin#removeMembersFromConsumerGroup method.

Code Block
languagejava
/**
 * Remove members from the consumer group by given member identities.
 * <p>
 * For possible error codes, refer to {@link LeaveGroupResponse}.
 *
 * @param groupId The ID of the group to remove member from.
 * @param reason The reason why the member left the group.
 * @param options The options to carry removing members' information.
 * @return The MembershipChangeResult.
 */
RemoveMembersFromConsumerGroupResult removeMembersFromConsumerGroup(String groupId, String reason, RemoveMembersFromConsumerGroupOptions options);@InterfaceStability.Evolving
public class RemoveMembersFromConsumerGroupOptions extends AbstractOptions<RemoveMembersFromConsumerGroupOptions> {
  /**
   * Sets an optional reason.
   */
  void reason(final String reason);
  
  /**
   * Returns the optional reason or an empty String if not defined.
   */
  String reason();
}

Consumer API

The reason is added as an argument to enforceRebalance method.

Code Block
languagejava
/**
 * @see KafkaConsumer#enforceRebalance()
 */
void enforceRebalance(final String reason);

Proposed Changes

The KIP adds a per-member field called Reason to the LeaveGroupRequest. The field will be populated with the leaving reason by the Consumer when it wants to leave the group. The consumer already logs the reason so we will reuse the same message. The field will be populated by the AdminClient as well when removeMembersFromConsumerGroup is called. In this case, the reason will be "member was removed by an admin" by default or the provided reason prefixed by "member was removed by an admin".

The KIP also adds a field called Reason to the JoinGroupRequest. The field will be populated with the reason why the joining reason by the Consumer. This will be really helpful to understand why a rebalance is triggered. The field will be populated by the Consumer as well when enforceRebalance is called. In this case, the reason will be "rebalance enforced by user" by default or the provided reason prefixed by "rebalance enforced by user:".

Compatibility, Deprecation, and Migration Plan

...