Interface ShareAcknowledgment
Share groups enable cooperative consumption where multiple consumers can process records from the same partitions. Each record must be explicitly acknowledged to indicate the result of processing.
Acknowledgment types:
ACCEPT- Record processed successfullyRELEASE- Temporary failure, make available for retryREJECT- Permanent failure, do not retryRENEW- Extend the acquisition lock (non-terminal; a terminal ack is still required)
This interface is only applicable when using explicit acknowledgment mode
(share.acknowledgement.mode=explicit). In implicit mode, records are
automatically acknowledged as ACCEPT.
Note: Acknowledgment is separate from commit operations. After acknowledging
records, use commitSync() or commitAsync() to persist the
acknowledgments to the broker.
- Since:
- 4.0
- Author:
- Soby Chacko
-
Method Summary
Modifier and TypeMethodDescriptionvoidAcknowledge the record as successfully processed.voidreject()Reject the record due to a permanent failure.voidrelease()Release the record for redelivery due to a transient failure.voidrenew()Renew the acquisition lock on the record without changing its outcome.
-
Method Details
-
acknowledge
void acknowledge()Acknowledge the record as successfully processed.The record will be marked as completed and will not be redelivered. The acknowledgment will be committed when:
- The next
poll()is called (batched with fetch) commitSync()orcommitAsync()is explicitly called- The consumer is closed
- Throws:
IllegalStateException- if the record has already been acknowledged- Since:
- 4.0
- The next
-
release
void release()Release the record for redelivery due to a transient failure.The record will be made available for another delivery attempt. The acknowledgment will be committed when:
- The next
poll()is called (batched with fetch) commitSync()orcommitAsync()is explicitly called- The consumer is closed
- Throws:
IllegalStateException- if the record has already been acknowledged
- The next
-
reject
void reject()Reject the record due to a permanent failure.The record will not be delivered again and will be archived. The acknowledgment will be committed when:
- The next
poll()is called (batched with fetch) commitSync()orcommitAsync()is explicitly called- The consumer is closed
- Throws:
IllegalStateException- if the record has already been acknowledged
- The next
-
renew
void renew()Renew the acquisition lock on the record without changing its outcome.Use when processing may exceed the broker's lock duration (
group.share.record.lock.duration.ms, default 30 seconds). The broker will extend the lock so the record is not redelivered while processing continues.This is non-terminal: you may call
renew()multiple times, but you must still call exactly one ofacknowledge(),release(), orreject()when processing completes.The acknowledgment will be committed when:
- The next
poll()is called (batched with fetch) commitSync()orcommitAsync()is explicitly called- The consumer is closed
- Throws:
IllegalStateException- if the record has already been terminally acknowledged (viaacknowledge(),release(), orreject())- Since:
- 4.1
- The next
-