Skip to content

KAFKA - Implementation for OMS ( Order Management System ) Step by Step

Notifications You must be signed in to change notification settings

TravelXML/KAFKA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KAFKA 🚀

KAFKA - Implementation with Node.js & Kafkajs - Order Management System / Inventory management System

Case Study

In a scenario where an order management system (oms) needs to publish stock or inventory of SKUs based on company ID and channel ID.

Prerequisites

Commands

What is ZooKeeper?

ZooKeeper is a high-performance coordination service for distributed applications. It provides common services such as naming, configuration management, synchronization, and group services.

  • Start ZooKeeper Container and expose default PORT 2181:

    docker run -p 2181:2181 zookeeper
  • Start Kafka Container, expose default PORT 9092, and set up ENV variables:

    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

File Structure

File Structure

First Run Publisher

Running the Producer Script

  1. Navigate to Your Project Directory:

    cd your_project_directory

    Or You can pull from DockerHub

    docker pull apige/kafka-node-inventory-update-for-oms-by-companyid-channelid:latest
  2. Execute the Producer Script to publish your inventory by sku level:

    node producer.js
  3. Provide Input When Prompted: The script will prompt you to enter the following details:

    • company_id
    • channel_id
    • sku_code
    • no_of_inventory

    Enter the values in the following format:

    5432 365667 345 8
    • company_id: 5432
    • channel_id: 365667
    • sku_code: 345
    • no_of_inventory: 8

Publisher Output

Then Run Consumer

Running the Consumer Script to consume the inventory updates by sku level

  1. Execute the Consumer Script with User Name:

    node consumer.js user-1
  2. Output Example: When you run the consumer script with a specific user name (user-1 in this case), you will receive output similar to the following:

    Consumer Output

    • user-1 is the group name: Indicates the group name being used by the consumer script.
    • Consumer connected: Confirmation that the consumer is connected.
    • Log messages from the Kafka consumer library (Kafkajs) indicating the start of consumption and group membership details.
    • user-1: [inv-updates]: PART:0: {"company":"5432","channelId":"365667","skuCode":"345","inv":"8"}: Represents the consumed message, indicating the user, topic, partition, and message content.

Releases

No releases published

Packages

No packages published