https://github.com/alexsergey/nest-kafka
Test kafka integration to Nestjs
https://github.com/alexsergey/nest-kafka
Last synced: about 1 year ago
JSON representation
Test kafka integration to Nestjs
- Host: GitHub
- URL: https://github.com/alexsergey/nest-kafka
- Owner: AlexSergey
- Created: 2022-05-19T09:41:41.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-01-14T18:08:36.000Z (over 2 years ago)
- Last Synced: 2024-04-14T11:08:30.734Z (about 2 years ago)
- Language: TypeScript
- Size: 340 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Roadmap: roadmap.md
Awesome Lists containing this project
README
# Nestjs + Kafkajs integration
This is test project to connect nestjs and kafkajs.
Includes docker-compose with:
- zookeeper
- kafka cluster
- kafka-ui
- kafdrop
## Installation
Go to "consumer" folder and run:
```shell
npm install
```
Go to "producer" folder and run:
```shell
npm install
```
In the root project's folder run:
```shell
docker-compose up
```
### Usage
After running docker containers you should run producer and consumer.
Please, use the following command:
```shell
npm start
```
Producer will be available on the link:
[producer link](http://localhost:3000)
After opening it in the Browser producer will fire event to consumer
### Console usage
Console usage snippets:
- Check ZooKeeper is running:
```shell
telnet localhost 2181
```
After you see "Connected to localhost.", put this code:
```shell
srvr
```
- Consumer
```shell
kafka-console-consumer \
--topic "say.hello" \
--bootstrap-server localhost:9092
```
- Producer
```shell
kafka-console-producer \
--topic "say.hello" \
--bootstrap-server localhost:9092
```
To use key:value notation:
```shell
kafka-console-producer \
--topic "say.hello" \
--bootstrap-server localhost:9092 \
--property parse.key=true \
--property key.separator=":"
```
Schema-registry. Delete subject:
```shell
curl -X DELETE http://localhost:8085/subjects/{subject_name}/versions/1
```
### Tools
- [kafka-ui](http://localhost:8081)
- [kafdrop](http://localhost:8082)