NestJs Hybrid Http and NestJs Kafka Microservice.
Fork from ack-nestjs-boilerplate
Before run, you must to create the topics with kafka-topics cli. Or you can run yarn kafka:create-topics. (Point 9 at 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 partitionand1 replication factor - Set
maxInFlightRequeststo1in consumer config - Use
producerSendSequentialorproduceEmitSequential
- Create topic with
emitmeans that whether or not you explicitly subscribe to the observable, the proxy will immediately try to deliver the event.sendmeans that you have to explicitly subscribe to it before the message will be sent.ackswill depends on kafka setting. Unfortunately, nestjs can not set acks when produce some message.- Topics in
./src/kafka/constants/kafka.topic.constant.tsmust created before running. - All kafka request will validate with
class-validationif you set the dto class. - Put KafkaController into
./src/kafka/router/kafka.router.module.ts, so you can useenv.KAFKA_CONSUMER_ENABLEfor on/off
- Kafka Transaction