Skip to content

Topic exchanges support for RabbitMQ (routing) #14535

Closed
@its-dibo

Description

@its-dibo

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

I created a microservice using NestFactory.createMicroservice and added a @EventPattern like this

@EventPattern('msg')
msg(){
 console.log('msg')
}

@EventPattern('*')
all(){
 console.log('all')
}

navigating to RabbitMQ UI, I can see the queue created successfully and bind to the default channel, but when I try to publish a message from there

{ "pattern": "msg" }

RabbitMQ tells that the message is routed, but I always get ERROR [Server] There is no matching event handler defined in the remote service. Event pattern: msg

I tried to create a minimal repo, but the app doesn't continue after app.listen() statement, I,.e app2 never logged
anyway, I just created a basic microservice in a totally new app
https://stackblitz.com/edit/nestjs-typescript-starter-qknpqrbp?file=src%2Fmain.ts

Minimum reproduction code

https://stackblitz.com/edit/nestjs-typescript-starter-qknpqrbp?file=src%2Fmain.ts

Steps to reproduce

1- replace NestFactory.create() with NestFactory.createMicroservice() and provide urls and queue
2- navigate to the RabbitMQ management UI to confirm the queue is created
3- publish a message from the created queue in RabbitMQ UI, the message is routed
4- NestJs logs an error that the pattern has not defined

Expected behavior

the message is catched by @EventPattern('msg') or even @EventPattern('*')

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

11.0.6

Packages versions

"@nestjs/core": "^11.0.6"
"dependencies": {
    "@nestjs/common": "^11.0.6",
    "@nestjs/config": "^4.0.0",
    "@nestjs/core": "^11.0.6",
    "@nestjs/event-emitter": "^3.0.0",
    "@nestjs/microservices": "^11.0.6",
    "@nestjs/platform-express": "^11.0.6",
    "@nestjs/platform-fastify": "^11.0.6",
    "@nestjs/platform-socket.io": "^11.0.6",
    "@nestjs/swagger": "^11.0.3",
    "@nestjs/typeorm": "^11.0.0",
    "@nestjs/websockets": "^11.0.6",
    "amqp-connection-manager": "^4.1.14",
    "amqplib": "^0.10.5",
    "array-flatten": "^3.0.0",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.1",
    "fastify": "^5.2.1",
    "kill-port": "^2.0.1",
    "pg": "^8.13.1",
    "reflect-metadata": "^0.2.2",
    "socket.io": "^4.8.1",
    "tslib": "^2.8.1",
    "typeorm": "^0.3.20"
  },
  "devDependencies": {
    "@jest/globals": "^29.7.0",
    "@nestjs/cli": "^11.0.2",
    "@nestjs/schematics": "^11.0.0",
    "@nestjs/testing": "^11.0.6",
    "@types/node": "^22.12.0",
    "dotenv": "^16.4.7",
    "kill-port": "^2.0.1",
    "nodemon": "^3.1.9",
    "prettier": "^3.4.2",
    "semantic-release": "^24.2.1",
    "semantic-release-monorepo": "^8.0.2",
    "ts-node": "^10.9.2",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.7.3"
  }
</details>

Node.js version

v22.12.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions