Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

368
Views
I am trying to consume kafka message from kafkajs, but not able to read the message,

I am trying to consume kafka message from kafkajs, but not able to read the message, please can you let me know the issue. Any Idea how to resolve this?

const kafka = new Kafka({
    logLevel: logLevel.INFO,
    ssl: true,
    brokers: ['b-1.dev-datafabric.nmz564.c20.kafka.us-east-1.amazonaws.com:9094',
        'b-2.dev-datafabric.nmz564.c20.kafka.us-east-1.amazonaws.com:9094',
        'b-3.dev-datafabric.nmz564.c20.kafka.us-east-1.amazonaws.com:9094'
    ],
    clientId: 'local-client'
})

const topic = 'aws.identity.users.0'
const consumer = kafka.consumer({
    groupId: 'test-group'
})
const consumedMessages = []

const run = async () => {
    await consumer.connect()
    await consumer.subscribe({
        topic,
        fromBeginning: true
    })
    await consumer.run({
        autoCommit: false,
        eachMessage: async ({
            topic,
            partition,
            message
        }) => {
            `not able to get inside this`
            consumedMessages.push(message);
            const prefix = `${topic}[${partition} | ${message.offset}] / ${message.timestamp}`
            console.log(`- ${prefix} ${message.key}#${message.value}`)

        },
    })
}
`how to make this code work`
app.get('/', (req, res) => {
    res.send('Hello World!')
    run().catch(e => console.error(`[example/consumer] ${e.message}`, e));
});

app.listen(port, () => {
    console.log(`Example app listening on port ${port}!`)
});

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!