Junior — Middle
Do you have practical experience working with Kafka system?
sobes.tech AI
Answer from AI
Yes, I have practical experience working with Apache Kafka in Node.js projects. I used the kafkajs library to implement message producers and consumers. For example, I created services that send events to Kafka for asynchronous processing and scalable data transfer between microservices.
Here's an example of a simple producer in Node.js using kafkajs:
const { Kafka } = require('kafkajs');
const kafka = new Kafka({
clientId: 'my-app',
brokers: ['kafka-broker1:9092', 'kafka-broker2:9092']
});
const producer = kafka.producer();
async function sendMessage() {
await producer.connect();
await producer.send({
topic: 'test-topic',
messages: [
{ value: 'Hello, Kafka!' }
]
});
await producer.disconnect();
}
sendMessage().catch(console.error);
This approach allows for efficient processing of large data volumes and building resilient distributed systems.