Skip to content

deepak04112002/kafka

Repository files navigation

Kafka Crash Course

Overview

This project demonstrates how to set up and use Apache Kafka with Docker and Node.js. It includes examples of Kafka producer, consumer, and admin functionalities.

Prerequisites

Docker Setup

  1. Start Zookeeper Container

    docker run -p PORTNO:PORTNO zookeeper
    
  2. Start Kafka Container

    docker run -p 9092:9092 \
    -e KAFKA_ZOOKEEPER_CONNECT=<PRIVATE_IP>:2181 \
    -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://<PRIVATE_IP>:9092 \
    -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
    confluentinc/cp-kafka

Node Setup

  1. Run the Kafka Admin Script

    node admin.js
  2. Run the Kafka Producer

    node producer.js
  3. Run the Kafka Consumer

    node consumer.js

Example Output

  1. node admin.js

    Admin connecting...
    Admin Connection Success...
    Creating Topic [rider-updates]
    Topic Created Success [rider-updates]
    Disconnecting Admin..
  2. node producer.js

    connecting Producer
    producer connected
    producer disconnected
  3. node consumer.js group1

    group1: [rider-updates]: PART:0: {"name":"tony","location":"south"}
    group1: [rider-updates]: PART:1: {"name":"tony","location":"north"}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published