#How does NestJS handle bindings in RabbitMQ Server?

1 messages · Page 1 of 1 (latest)

obsidian wraith
#

I've read the source code for the rmq server and it looks like nest doesnt bind the queue to any key if the key is not specified in topic mode
it only binds in case wildcards is set to true, am I missing something? or are you supposed to handle it manually
server code:
https://github.com/nestjs/nest/blob/master/packages/microservices/server/server-rmq.ts

GitHub

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀 - nestjs/nest

twilit lodge
#

Ah yeah, that's exactly how it works.
By default, in topic mode, Nest only binds queues when you either specify a routing key explicitly or use wildcards(#/*)
If you don't do either, nest leaves it unbound, you're expected to handle the binding manually if you need a default route.
It's a bit unintuitive, I agree.
Honestly, for topic exchanges I usually always set and explicit routing key or a #wildcard so the queue actually receives messages.

obsidian wraith
twilit lodge
# obsidian wraith but so Like if you have wildcards as true its going to bind each key by iteratin...

Yeah, basically yes. with wildcards:true Nest iterates over the consumers and binds using their patterns.
Why not do it for all decorated consumers by default? Mostly design choice+backward compatibility. Nest tries to stay explicit here and avoids “magic” bindings that could accidentally subscribe you to more topics than intended.
I agree though, an opt-in flag like autoBindPatterns:true would make sense. if you want that behavior, you kinda have to handle the binding yourself or always use #/explicit keys rn.

obsidian wraith