3. Acknowledge the records based on some ID like offset

shareConsumer.acknowledge(record.offset(), ACCEPT); 

Regards,
Shekhar Prasad Rajak,
Contact : +918142478937Blog | Github | Twitter
 

    On Friday 29 August 2025 at 11:37:24 am GMT+5:30, RShekhar Prasad 
<rshekhar.pra...@gmail.com> wrote:  
 
 Hello team,
While exploring Kafka Queue semantics, we released there is some APIs that is 
useful but missing for example :
1.  Multiple polls and ack later batch wise in explicit mode : 

 ConsumerRecords<K, V> batch1 = shareConsumer.poll(Duration.ofMillis(100));
 ConsumerRecords<K, V> batch2 = shareConsumer.poll(Duration.ofMillis(100)); // 
No IllegalStateException!
 ConsumerRecords<K, V> batch3 = shareConsumer.poll(Duration.ofMillis(100));
 
 // Process all batches...
 shareConsumer.acknowledgeBatch(batch1, AcknowledgeType.ACCEPT);
 shareConsumer.acknowledgeBatch(batch2, AcknowledgeType.ACCEPT);
 shareConsumer.acknowledgeBatch(batch3, AcknowledgeType.ACCEPT);
shareConsumer.commitSync(); // Commit all acknowledged batches
If we have these APIs available then multiple threads can keep polling and 
committing once their processing is done, before the timeout (and release).
In Implicit mode, we might miss(fail) the processing of the record but ACCEPT 
acknowledge in each poll(), hence that will not help in at least once semantics.
2.  ack all API:
 shareConsumer.acknowledgeAll(AcknowledgeType.ACCEPT); 
shareConsumer.commitSync();

Do you guys have any thought on this ? 

Regards,
Shekhar Prasad Rajak,
Blog | Github | Twitter
  

Reply via email to