Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iam-abhishek-yadav/kafka-app
https://github.com/iam-abhishek-yadav/kafka-app
docker-compose kafkajs nodejs zookeeper
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/iam-abhishek-yadav/kafka-app
- Owner: iam-abhishek-yadav
- Created: 2024-06-26T16:55:27.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-06-26T17:12:05.000Z (6 months ago)
- Last Synced: 2024-06-26T21:18:48.930Z (6 months ago)
- Topics: docker-compose, kafkajs, nodejs, zookeeper
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
**Prerequisites:**
- Node.js (version 12 or higher)
- npm (Node Package Manager)
- Docker (if running Kafka locally using Docker)**Setup:**
- **Clone the Repository**
```bash
git clone https://github.com/iam-abhishek-yadav/kafka-app
cd kafka-app
```- **Install Dependencies**
```bash
npm install
```This will install the necessary packages, including `kafkajs`, used for Kafka communication.
- **Start Kafka and Kafka UI**
```bash
docker-compose up -d
```Kafka UI will be accessible at `http://localhost:8080`.
**Running the Scripts:**
- **Run Admin Script**
The admin script (`admin.js`) initializes the Kafka admin client to manage Kafka topics.
```bash
node admin.js
```- **Open Consumer Terminals**
Open three new terminal windows (or tabs) to run the consumer scripts concurrently:
- **Consumer 1 (Same Group)**:
```bash
node consumer.js group1
```- **Consumer 2 (Same Group)**:
```bash
node consumer.js group1
```- **Consumer 3 (Different Group)**:
```bash
node consumer.js group2
```Replace `group1` and `group2` with your desired consumer group names.
These consumers will subscribe to the Kafka topic and receive messages based on their group subscriptions.
- **Run Producer Script**
Open another new terminal window (or tab) to run the producer script:
```bash
node producer.js
```This script allows you to send messages to the Kafka topic `rider-status`.
- **Input Example**:
Input should be formatted as ` `. For example:
```
John north
Alice south
```Enter each rider's name and location separated by a space and press `Enter` to send the message.
- **Access Kafka UI:** [http://localhost:8080](http://localhost:8080)