Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chetanxpro/kafka-basics
Explore Kafka Basics: Set up topics, partitions, consumers, and producers using Node.js scripts.
https://github.com/chetanxpro/kafka-basics
kafka kafka-admin kafka-consumer kafka-producer nodejs
Last synced: about 6 hours ago
JSON representation
Explore Kafka Basics: Set up topics, partitions, consumers, and producers using Node.js scripts.
- Host: GitHub
- URL: https://github.com/chetanxpro/kafka-basics
- Owner: ChetanXpro
- Created: 2023-08-27T17:17:14.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-27T19:53:56.000Z (about 1 year ago)
- Last Synced: 2024-05-18T03:45:41.191Z (6 months ago)
- Topics: kafka, kafka-admin, kafka-consumer, kafka-producer, nodejs
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kafka Basic Functionality Project
This project demonstrates the basic functionality of Apache Kafka, a distributed event streaming platform. It covers the creation of topics and partitions, as well as the setup of consumers and producers in a Node.js environment.
## Commands
- Start Zookeper Container and expose PORT 2181.
```docker run -p 2181:2181 zookeeper```
- Start Kafka Container, expose PORT 9092 and setup ENV variables.
```
docker run -p 9092:9092 \
-e KAFKA_ZOOKEEPER_CONNECT=:2181 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://:9092 \
-e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
confluentinc/cp-kafka
```## Getting Started
To get started with the project, follow these steps:
1. **Installation:** Make sure you have Node.js and Kafka installed on your machine. If not, refer to the official documentation for installation instructions.
2. **Clone the Repository:** Clone this repository to your local machine using the following command:
```bash
git clone https://github.com/ChetanXpro/kafka-basics.git## Admin
- The `admin.js` script is responsible for creating topics and partitions for those topics. The script uses the Kafka admin client to perform administrative tasks. It's an essential step to set up the topics before running consumers and producers.
- To execute the admin script:
- ``` node admin.js```## Setting Up Consumers
- Run a consumer and specify a consumer group.
- ``` node consumer.js group-1```## Producing Data
- Run the producer to send data to a Kafka topic.
```
node producer.jsEXAMPLE: node producer.js chetan delhi
```