ack-nestjs-boilerplate-kafka
ack-nestjs-boilerplate-kafka copied to clipboard
Hybrid NestJs v9.x Boilerplate. Repository Design Pattern. Kafka Microservice. MongoDB(mongoose). Support Containerization.
NestJs Boilerplate Ack Kafka
NestJs Hybrid Http and NestJs Kafka Microservice.
Fork from ack-nestjs-boilerplate
Instructions
Before run, you must to create the topics with kafka-topics cli
. Or you can run yarn kafka:create-topics
. (Point 9 at Behaviour)
Behaviour
- Producer and consumer will use
nestjs/microservice
- Producer will always imported as global module
- Message not commit offset in error
- Optional commit offset in first running
- Default kafka will create topic with 3 partition and 3 replication factor
- For guarantee sequential
- Create topic with
1 partition
and1 replication factor
- Set
maxInFlightRequests
to1
in consumer config - Use
producerSendSequential
orproduceEmitSequential
- Create topic with
-
emit
means that whether or not you explicitly subscribe to the observable, the proxy will immediately try to deliver the event. -
send
means that you have to explicitly subscribe to it before the message will be sent. -
acks
will depends on kafka setting. Unfortunately, nestjs can not set acks when produce some message. - Topics in
./src/kafka/constants/kafka.topic.constant.ts
must created before running. - All kafka request will validate with
class-validation
if you set the dto class. - Put KafkaController into
./src/kafka/router/kafka.router.module.ts
, so you can useenv.KAFKA_CONSUMER_ENABLE
for on/off
Next
- [ ] Kafka Transaction