This project is a simple Node.js application that simulates a Kafka producer and consumer. It utilizes the kafka-node
library to interact with Apache Kafka. The producer sends mock messages to a Kafka topic at specified intervals, and the consumer listens to the same topic, logging the received messages.
Kafka is a distributed event streaming platform widely used for building real-time data pipelines and streaming applications. This application provides a basic simulation of a Kafka setup, demonstrating the interaction between a producer that sends messages and a consumer that receives and logs these messages.
Before running the application, ensure you have the following installed:
- Node.js and npm
- Docker
- Docker Compose
To simplify the setup, this project includes a docker-compose.yml
file. Docker Compose allows you to define and run multi-container Docker applications.
-
Start the Kafka broker:
docker-compose up -d
-
Verify that Kafka and Zookeeper containers are running:
docker-compose ps
-
Clone the repository:
git clone https://github.com/your-username/your-repository.git
-
Navigate to the project directory:
cd your-repository
-
Install dependencies:
npm install
Update Kafka broker settings in config/index.js
:
module.exports = {
kafka: {
kafkaHost: 'localhost:9092',
topic: 'local-kafka-case-events',
},
producerInterval: 5000,
};