nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
68.15k stars 7.67k forks source link

kafka consumer don't subscribe topics when consumer restart #9484

Closed lzw621558 closed 2 years ago

lzw621558 commented 2 years ago

Is there an existing issue for this?

Current behavior

when i write a hybrid application, build to docker image. if the kafka brokers all down,the consumer will stop and restart. but if the consumer restart, it will lost all the topic info,none topic will be subscribed. image

you can see the memberAssignment is null, and no message will be received from kafka.

nomal case: image

Minimum reproduction code

https://github.com/lzw621558/nest-kafka/tree/feat/issue

Steps to reproduce

npm install npm run start then stop the kafka broker when the consumer has stoped,start the kafka broker again

Expected behavior

the topics define in kafka controllers will be re subscribed when consumer restart.

Package

Other package

No response

NestJS version

No response

Packages versions

{
  "name": "bw-fdma-bff",
  "version": "0.10.30",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "scripts": {
    "prebuild": "rimraf dist",
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  },
  "dependencies": {
    "@nestjs/axios": "^0.0.4",
    "@nestjs/common": "^8.0.0",
    "@nestjs/config": "^1.1.6",
    "@nestjs/core": "^8.0.0",
    "@nestjs/jwt": "^8.0.0",
    "@nestjs/microservices": "^8.2.6",
    "@nestjs/mongoose": "^9.0.2",
    "@nestjs/passport": "^8.1.0",
    "@nestjs/platform-express": "^8.0.0",
    "@nestjs/platform-socket.io": "^8.2.6",
    "@nestjs/schedule": "^1.1.0",
    "@nestjs/swagger": "^5.1.5",
    "@nestjs/terminus": "^8.0.4",
    "@nestjs/typeorm": "^8.0.3",
    "@nestjs/websockets": "^8.2.6",
    "axios": "^0.25.0",
    "bcryptjs": "^2.4.3",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.13.2",
    "kafkajs": "^1.15.0",
    "mongoose": "^6.2.3",
    "mysql2": "^2.3.3",
    "nest-winston": "^1.6.2",
    "nestjs-i18n": "^9.0.5",
    "passport": "^0.5.2",
    "passport-jwt": "^4.0.0",
    "passport-local": "^1.0.0",
    "qs": "^6.10.3",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.2",
    "rxjs": "^7.2.0",
    "socket.io": "^4.4.1",
    "string-random": "^0.1.3",
    "swagger-ui-express": "^4.3.0",
    "typeorm": "^0.2.41",
    "winston": "^3.4.0",
    "winston-mongodb": "^5.0.7"
  },
  "devDependencies": {
    "@compodoc/compodoc": "^1.1.19",
    "@nestjs/cli": "^8.0.0",
    "@nestjs/schematics": "^8.0.0",
    "@nestjs/testing": "^8.0.0",
    "@types/bcryptjs": "^2.4.2",
    "@types/express": "^4.17.13",
    "@types/jest": "^27.0.1",
    "@types/kafkajs": "^1.9.0",
    "@types/node": "^16.0.0",
    "@types/passport-jwt": "^3.0.6",
    "@types/passport-local": "^1.0.34",
    "@types/supertest": "^2.0.11",
    "@typescript-eslint/eslint-plugin": "^4.28.2",
    "@typescript-eslint/parser": "^4.28.2",
    "eslint": "^7.30.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^3.4.0",
    "jest": "^27.0.6",
    "prettier": "^2.3.2",
    "supertest": "^6.1.3",
    "ts-jest": "^27.0.3",
    "ts-loader": "^9.2.3",
    "ts-node": "^10.0.0",
    "tsconfig-paths": "^3.10.1",
    "typescript": "^4.3.5"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node"
  }
}

Node.js version

16.13.2

In which operating systems have you tested?

Other

No response

kamilmysliwiec commented 2 years ago

Please provide a minimum reproduction repository (Git repository).

lzw621558 commented 2 years ago

Please provide a minimum reproduction repository (Git repository).

has already updated.

Marwan-Amin commented 1 year ago

I have countred the same issue, can any one know how to solve this ??

fabianboerner commented 1 year ago

this is closed, have the same problem!