Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4870

How to use Kafkajs in ember?

$
0
0

I have installed kafkajs package using the command npm install kafkajs

but ember can’t found Kafka package.

I got this exception

Source Code

**const { Kafka } = require(‘kafkajs’)

const kafka = new Kafka({ clientId: ‘my-app’, brokers: [‘kafka1:9092’, ‘kafka2:9092’] })

const producer = kafka.producer() const consumer = kafka.consumer({ groupId: ‘test-group’ })

const run = async () => { // Producing await producer.connect() await producer.send({ topic: ‘test-topic’, messages: [ { value: ‘Hello KafkaJS user!’ }, ], })

// Consuming await consumer.connect() await consumer.subscribe({ topic: ‘test-topic’, fromBeginning: true })

await consumer.run({ eachMessage: async ({ topic, partition, message }) => { console.log({ partition, offset: message.offset, value: message.value.toString(), }) }, }) }**

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 4870

Trending Articles