CCDAK practice question 14 of 25
A consumer is configured with enable.auto.commit=false. What happens when close() is called on the consumer object?
Full set: 150 questionsCalling the close() method on a Kafka consumer instance initiates a graceful shutdown. As part of this process, the consumer sends a LeaveGroup request to the group coordinator. Upon receiving this request, the coordinator immediately triggers a rebalance of the consumer group to reassign the partitions from the departing consumer to the remaining active members. This ensures that processing continues with minimal delay and avoids the need to wait for a session timeout to detect a failed consumer. The enable.auto.commit=false setting does not alter this graceful shutdown behavior.
A. The uncommitted offsets are committed The close() method only commits offsets if enable.auto.commit is set to true. The question explicitly states this configuration is false.
C. The group coordinator will discover that the consumer stopped sending heartbeats. It will cause rebalance after session.timeout.ms This describes an ungraceful shutdown or failure (e.g., a crash). A graceful shutdown via close() proactively notifies the coordinator, triggering an immediate rebalance. ---
1. Apache Kafka Documentation (Javadoc for KafkaConsumer): The official Javadoc for the org.apache.kafka.clients.consumer.KafkaConsumer class specifies the behavior of the close() method. It states, "If auto-commit is enabled, this will commit the current offsets." This implies that if auto-commit is disabled, no commit occurs on close, invalidating option A. The method's purpose is to "part with the group," which is the graceful leave action described in option B.
Source: Apache Kafka 3.x Javadoc, org.apache.kafka.clients.consumer.KafkaConsumer.close() method description.
2. Confluent Documentation, "Rebalances": This document explains the consumer group protocol. It distinguishes between graceful and ungraceceful shutdowns. "When a consumer is shut down cleanly, it will notify the group coordinator that it is leaving the group. The group coordinator will immediately trigger a rebalance to re-assign its partitions to another consumer in the group." This directly supports option B and refutes option C.
Source: Confluent Documentation -> Apache Kafka -> Rebalances -> "What is a rebalance?" section.
3. "Kafka: The Definitive Guide, 2nd Edition" by Narkhede, N., Shapira, G., & Palino, T. (O'Reilly Media, 2021): This authoritative book, written by Kafka's creators, details the consumer group protocol.
Source: Chapter 4, "Kafka Consumers: Reading Data from Kafka", Section "The Group Coordinator and Consumer Groups". It states: "When the consumer wishes to leave the group, it will notify the coordinator. The coordinator will start a rebalance..." This confirms the immediate rebalance on a clean exit. The subsequent section, "Detecting Consumer Failures," explains that the session.timeout.ms mechanism is for failures, not clean shutdowns.
Keep practicing
Take the free CCDAK practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other CCDAK practice questions
- Question 1In Avro, removing or adding a field that has a default is a __ schema evolution
- Question 2A topic has three replicas and you set min.insync.replicas to 2. If two out of three repl…
- Question 3To get acknowledgement of writes to only the leader partition, we need to use the config.…
- Question 4A customer has many consumer applications that process messages from a Kafka topic. Each …
- Question 5What information isn't stored inside of Zookeeper? (select two)
- Question 6If you enable an SSL endpoint in Kafka, what feature of Kafka will be lost?
