Class CloseOptions

java.lang.Object
org.apache.kafka.clients.consumer.CloseOptions

@Public public class CloseOptions extends Object
Options for controlling the consumer close behavior.

This class allows customization of the close timeout and group membership operation when a consumer is being shut down.

  • Method Details

    • timeout

      public static CloseOptions timeout(Duration timeout)
      Static method to create a CloseOptions with a custom timeout.
      Parameters:
      timeout - The maximum time to wait for the consumer to close.
      Returns:
      A new CloseOptions instance with the specified timeout.
    • groupMembershipOperation

      public static CloseOptions groupMembershipOperation(CloseOptions.GroupMembershipOperation operation)
      Static method to create a CloseOptions with a specified group membership operation.
      Parameters:
      operation - The group membership operation to apply. Must be one of LEAVE_GROUP, REMAIN_IN_GROUP, or DEFAULT.
      Returns:
      A new CloseOptions instance with the specified group membership operation.
    • withTimeout

      public CloseOptions withTimeout(Duration timeout)
      Fluent method to set the timeout for the close process.
      Parameters:
      timeout - The maximum time to wait for the consumer to close. If null, the default timeout will be used.
      Returns:
      This CloseOptions instance.
    • withGroupMembershipOperation

      public CloseOptions withGroupMembershipOperation(CloseOptions.GroupMembershipOperation operation)
      Fluent method to set the group membership operation upon shutdown.
      Parameters:
      operation - The group membership operation to apply. Must be one of LEAVE_GROUP, REMAIN_IN_GROUP, or DEFAULT.
      Returns:
      This CloseOptions instance.
    • groupMembershipOperation

      public CloseOptions.GroupMembershipOperation groupMembershipOperation()
      Returns the group membership operation configured for this close.
      Returns:
      The group membership operation
    • timeout

      public Optional<Duration> timeout()
      Returns the timeout configured for this close.
      Returns:
      The timeout, or empty if using the default timeout