rajeshkumarbehura / ts-nestjs-kafka

Exmaple to Integrate kafkajs with nestjs & kakfka
75 stars 24 forks source link

Nest Logo

Example of NestJs & KafkaJs integration simplified.

Description

This example built on Nest framework TypeScript starter repository.

It integrates with kafkajs and simplified to subscribe and publish message to kafka topics.

Find more in - https://dev.to/rajeshkumarbehura/kafkajs-nestjs-with-typescript-simplified-example-35ep

Installation

$ yarn install

Running the app

Step- 1

Make sure docker & docker-compose is installed.

# Run kafka server in local machine, go to docker folder 
$ docker-compose -f kafka.yml up
# To run kafka drop UI to monitor kafka in local machine, go to docker folder 
$ docker-compose -f kafka-drop-ui.yml up

After running Kafka Server & Kafka Drop UI successuflly, access kafka-drop monitoring UI http://localhost:9000

More on kafka drop Application - https://github.com/obsidiandynamics/kafdrop https://raw.githubusercontent.com/obsidiandynamics/kafdrop/master/docs/images/overview.png

Step- 2

Run the application

# development
$ yarn start

Step- 3

Send message to Kafka & receive message by consumer testing.

  1. http://localhost:3000/send/consumer - send a sample message to kafka & consumer receives and print in application log
  2. http://localhost:3000/send/fixed-consumer

When you call above api, application console log will print " [KAKFA-CONSUMER] ...." .

License

Nest is MIT licensed.