1.0.4 • Published 2 years ago

@guidecx/node-kafka-client v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

@GuideCX/node-kafka-client

This is a kafka client built for Node.js and is intended to be consumed by GuideCX Node.js micro services.

Pre-Requisites

  • Node.js LTS
  • Docker (verify install with docker -v and docker-compose -v)
  • Git Bash (if Windows)

Getting Started

Run Git Bash as an administrator (if windows)

Start Kafka in docker

docker compose up

Docker will spin up a local Kafka and Zookeeper instance. Zookeeper is needed to communicate with Kafka. In order to get Kafka running correctly.

This will verify that the client is pointed to the correct broker. It also verifies that the broker is reachable via a Kafka UI tool.

Kafka Tool

In order to better visualize the topics, partitions, and data in Kafka, you can use Kafka Tool. In order to connect to your local Kafka instance, use the following steps.

  1. Run
export HOST_IP=$(ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d: | head -n1)
docker-compose up
  1. Launch the Kafka Tool application
  2. You'll be prompted to purchase a work license. This isn't necessary so click close.
  3. If not prompted to already create a new connection, click Add New Collection.
  4. Name the cluster anything you'd like.
  5. The Zookeeper Host should be localhost
  6. The Zookeeper Port should be the port assigned to Zookeeper in docker-compose.yml
  7. Press connect

This should connect you with Zookeeper which should automatically connect you with your local Kafka instance. In the scenario that your broker (Kafka instance) is not auto connecting/loading, do the following:

  1. Verify that your cluster's security settings specify that you're using Plaintext.
  2. Verify that your broker's host is the HOST_IP you configured above. This can be verified by opening Docker Desktop, inspecting the Kafka service, and checking its ENV variables there.
Run Scripts
# get up and running for development
npm install
npm run test

Release New NPM Module

On master branch

npm version patch