I want to read batch of messages as following code works in java.
```try {
while (true) { 1
ConsumerRecords
for (ConsumerRecord
{
log.debug("topic = %s, partition = %d, offset = %d,"
customer = %s, country = %s\n",
record.topic(), record.partition(), record.offset(),
record.key(), record.value());
int updatedCount = 1;
if (custCountryMap.countainsKey(record.value())) {
updatedCount = custCountryMap.get(record.value()) + 1;
}
custCountryMap.put(record.value(), updatedCount)
JSONObject json = new JSONObject(custCountryMap);
System.out.println(json.toString(4))
}
}
} finally {
consumer.close();
}
```
Is this possible in go?
no - messages are delivered to your application one at a time.
note: behind the scenes, librdkafka is pulling messages from the brokers in batches in background threads and, with the default settings, buffers them aggressively - so performance is great. the one-at-a-time API is better for every use case we could thought of (is higher level).
Any usecase which requires batch processing would require to reimplement batch processing. Writing data to database. Applying ML models on GPU. Etc.
Most helpful comment
no - messages are delivered to your application one at a time.
note: behind the scenes, librdkafka is pulling messages from the brokers in batches in background threads and, with the default settings, buffers them aggressively - so performance is great. the one-at-a-time API is better for every use case we could thought of (is higher level).