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
67.63k stars 7.62k forks source link

[Processor] NestJS Processor not pick when use with app.startAllMicroservices() without use await app.listen() #13935

Closed huynhanhkhoa2895 closed 1 month ago

huynhanhkhoa2895 commented 2 months ago

Is there an existing issue for this?

Current behavior

I try to run Queue in Microservice but it does not trigger processor when I remove await app.listen(3001) Capture

And Queue work correctly when I still use the await app.listen(3001) Capture

Minimum reproduction code

https://github.com/huynhanhkhoa2895/test-nestjs

Steps to reproduce

No response

Expected behavior

I don't want to use await app.listen(3001); because I don't need to open the port. I just want to use only await app.startAllMicroservices();

Package

Other package

@nestjs/bull

NestJS version

10.0.0

Packages versions

{
  "name": "test",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "scripts": {
    "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": {
    "@grpc/grpc-js": "^1.11.1",
    "@grpc/proto-loader": "^0.7.13",
    "@nestjs/bull": "^10.2.1",
    "@nestjs/common": "^10.0.0",
    "@nestjs/config": "^3.2.3",
    "@nestjs/core": "^10.0.0",
    "@nestjs/microservices": "^10.4.1",
    "@nestjs/platform-express": "^10.0.0",
    "bull": "^4.16.1",
    "reflect-metadata": "^0.2.0",
    "rxjs": "^7.8.1"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.0.0",
    "@nestjs/schematics": "^10.0.0",
    "@nestjs/testing": "^10.0.0",
    "@types/express": "^4.17.17",
    "@types/jest": "^29.5.2",
    "@types/node": "^20.3.1",
    "@types/supertest": "^6.0.0",
    "@typescript-eslint/eslint-plugin": "^8.0.0",
    "@typescript-eslint/parser": "^8.0.0",
    "eslint": "^8.42.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.0",
    "jest": "^29.5.0",
    "prettier": "^3.0.0",
    "source-map-support": "^0.5.21",
    "supertest": "^7.0.0",
    "ts-jest": "^29.1.0",
    "ts-loader": "^9.4.3",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.1.3"
  },
  "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

20.12.1

In which operating systems have you tested?

Other

No response

micalevisk commented 2 months ago

Hi!

if you don't want to listen(port), why are you using NestFactory.create instead of NestFactory.createMicroservice? :thinking:

huynhanhkhoa2895 commented 2 months ago

Hi!

if you don't want to listen(port), why are you using NestFactory.create instead of NestFactory.createMicroservice? :thinking:

I also use kafka

synerp commented 2 months ago

I use async function bootstrap() { await NestFactory.createApplicationContext(AppModule); console.log(🚀 Kafka Consumer is running...); } bootstrap();

kamilmysliwiec commented 1 month ago

Thank you for taking the time to submit your report! From the looks of it, this could be better discussed on our Discord. If you haven't already, please join here and send a new post in the #⁠ 🐈 nestjs-help forum. Make sure to include a link to this issue, so you don't need to write it all again. We have a large community of helpful members, who will assist you in getting this to work.