confluentinc / confluentinc/confluent-kafka-javascript

KafkaJS Listen to commit offset callback

Open
#270 0 comments 0 reactions 0 assignees View on GitHub
status:waiting-for-interest
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.