Subscribe to queues without knowing the exchange and binding key (e.g. default exchange)
See original GitHub issueHey all, I am having real troubles understanding how golevelup expects me to know the exchange and routing key in advance, when I simply want to consume messages from a particular queue. As I understood it, the @RabbitSubscribe
decorator requires an exchange
and routingKey
, as shown in the example above:
@RabbitSubscribe({
exchange: 'exchange1',
routingKey: 'subscribe-route',
queue: 'subscribe-queue',
})
public async pubSubHandler(msg: {}) {
console.log(`Received message: ${JSON.stringify(msg)}`);
}
I understand, that golevelup dynamically creates the binding. But what happens, if there is no exchange? If any publisher publishes to amq.direct
(which is also the “empty string”), I have a valid queue, but neither an exchange nor binding (because rabbit routes the message implicitly and the queue name actually is the binding).
How am I supposed to subscribe to a typical pub-sub model where multiple exchanges and bindings might publish to the same queue? I have a landscape where the individual consumers are not supposed to know about other publishers and also do not care about the RabbitMQ configuration that routes messages to “their” queues. As long as they consume from the queues, they do not need to know about other exchanges and bindings.
Any help appreciated!
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
I plan to prepare the PR this week. We will see, if WonderPanda will approve it 😆 .
@j-schreiber No problem 😃 Feel free to ask if you have any questions and I can provide assistance