This is an automated email from the ASF dual-hosted git repository.
chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new f9df9b56528 KAFKA-19311 Document commitAsync behavioral differences
between Classic and Async Consumer (#19864)
f9df9b56528 is described below
commit f9df9b56528cd462e7ff8a388e082876b6c88008
Author: Ming-Yen Chung <[email protected]>
AuthorDate: Sun Jun 1 01:58:26 2025 +0800
KAFKA-19311 Document commitAsync behavioral differences between Classic and
Async Consumer (#19864)
#15613 ensures that all `commitAsync` callbacks are triggered before
`commitSync` completes for `AsyncKafkaConsumer`. However, the related
changes to `ClassicKafkaConsumer`, #15693, were not merged. I assume
this might be because we intend to gradually move toward using AsyncConsumer
instead.
In short, this behavioral difference should be documented.
Reviewers: Ken Huang <[email protected]>, Chia-Ping Tsai
<[email protected]>
---
.../org/apache/kafka/clients/consumer/KafkaConsumer.java | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git
a/clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java
b/clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java
index 0e7d3d65b1f..8bba69198a6 100644
--- a/clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java
+++ b/clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java
@@ -908,7 +908,8 @@ public class KafkaConsumer<K, V> implements Consumer<K, V> {
* (in which case a {@link
org.apache.kafka.common.errors.TimeoutException} is thrown to the caller).
* <p>
* Note that asynchronous offset commits sent previously with the {@link
#commitAsync(OffsetCommitCallback)}
- * (or similar) are guaranteed to have their callbacks invoked prior to
completion of this method.
+ * (or similar) are guaranteed to have their callbacks invoked prior to
completion of this method,
+ * but only when the consumer is using the consumer group protocol.
*
* @throws org.apache.kafka.clients.consumer.CommitFailedException if the
commit failed and cannot be retried.
* This fatal error can only occur if you are using automatic
group management with {@link #subscribe(Collection)},
@@ -952,7 +953,8 @@ public class KafkaConsumer<K, V> implements Consumer<K, V> {
* encountered (in which case it is thrown to the caller), or the passed
timeout expires.
* <p>
* Note that asynchronous offset commits sent previously with the {@link
#commitAsync(OffsetCommitCallback)}
- * (or similar) are guaranteed to have their callbacks invoked prior to
completion of this method.
+ * (or similar) are guaranteed to have their callbacks invoked prior to
completion of this method,
+ * but only when the consumer is using the consumer group protocol.
*
* @throws org.apache.kafka.clients.consumer.CommitFailedException if the
commit failed and cannot be retried.
* This can only occur if you are using automatic group
management with {@link #subscribe(Collection)},
@@ -1001,7 +1003,8 @@ public class KafkaConsumer<K, V> implements Consumer<K,
V> {
* (in which case a {@link
org.apache.kafka.common.errors.TimeoutException} is thrown to the caller).
* <p>
* Note that asynchronous offset commits sent previously with the {@link
#commitAsync(OffsetCommitCallback)}
- * (or similar) are guaranteed to have their callbacks invoked prior to
completion of this method.
+ * (or similar) are guaranteed to have their callbacks invoked prior to
completion of this method,
+ * but only when the consumer is using the consumer group protocol.
*
* @param offsets A map of offsets by partition with associated metadata.
This map will be copied internally, so it
* is safe to mutate the map after returning.
@@ -1053,7 +1056,8 @@ public class KafkaConsumer<K, V> implements Consumer<K,
V> {
* encountered (in which case it is thrown to the caller), or the timeout
expires.
* <p>
* Note that asynchronous offset commits sent previously with the {@link
#commitAsync(OffsetCommitCallback)}
- * (or similar) are guaranteed to have their callbacks invoked prior to
completion of this method.
+ * (or similar) are guaranteed to have their callbacks invoked prior to
completion of this method,
+ * but only when the consumer is using the consumer group protocol.
*
* @param offsets A map of offsets by partition with associated metadata.
This map will be copied internally, so it
* is safe to mutate the map after returning.