confluentinc / confluentinc/confluent-kafka-javascript
KafkaJS Listen to commit offset callback
- Dominant language
- TypeScript
- Stars
- 304
- Forks
- 45
- Avg merge
- 11h 47m
- Merged PRs (30d)
- 5
Description
Hi,
I'm trying to listen ti commit event. I'm using confluent cloud as the Kafka Service.
This is the code, I copied from the documentation.
I see the consumere gets the message, the autoCommit is true by default by don't see the offset_commit_cb log.
const { Kafka, ErrorCodes } = require('@confluentinc/kafka-javascript').KafkaJS;
const kafka = new Kafka({
kafkaJS: {
groupId: "idoTest",
fromBeginning: true,
brokers: [ 'CLOUD:9092' ],
ssl: true,
sasl: {
mechanism: 'plain',
username: 'USERNAME',
password: 'PASSWORD'
}},
'offset_commit_cb': (err, offsets) => {
if (err) {
console.error(`Offset commit failed for offsets ${JSON.stringify(offsets)}: ${err}`);
} else {
console.log(`Successfully committed offsets ${JSON.stringify(offsets)}`);
}
},
});
const consumer = kafka.consumer();
async function run() {
await consumer.connect();
await consumer.subscribe({ topic: 'testIdo-a'});
await consumer.run({
eachMessage: async ({ topic, partition, message }) => {
console.log({
topic,
partition,
offset: message.offset,
value: message.value.toString(),
});
},
});
}
run().catch(e => console.error(`[example/consumer] ${e.message}`, e));
Contributor guide
Research direction
Start with the Kafka and consumer configuration shown in the issue, especially offset_commit_cb and consumer.run. Check how the JavaScript client handles automatic offset commits and whether this callback is supported in this configuration. Done means the callback behavior is explained and the documentation or implementation is corrected accordingly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, kafka
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100