question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Subscribe to queues without knowing the exchange and binding key (e.g. default exchange)

See original GitHub issue

Hey 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:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
j-schreibercommented, Sep 27, 2021

I plan to prepare the PR this week. We will see, if WonderPanda will approve it 😆 .

1reaction
WonderPandacommented, Sep 24, 2021

@j-schreiber No problem 😃 Feel free to ask if you have any questions and I can provide assistance

Read more comments on GitHub >

github_iconTop Results From Across the Web

Part 4: RabbitMQ Exchanges, routing keys and bindings
Direct Exchange: A message goes to the queues whose binding key exactly matches the routing key of the message. Default exchange. The default...
Read more >
AMQP 0-9-1 Model Explained - RabbitMQ
The default exchange is a direct exchange with no name (empty string) pre-declared by the broker. It has one special property that makes...
Read more >
RabbitMQ Exchanges: Key Models, Keys, and Bindings Made ...
The default exchange in RabbitMQ Exchanges is a pre-declared (empty string) direct exchange with no name. The default exchange will deliver the ...
Read more >
RabbitMQ Exchange Types - Medium
Every queue is automatically bound to the default exchange with a routing key which is the same as the queue name. If there...
Read more >
4.6.2. Publish to a Queue using the Default Exchange
All queues automatically bind to the default exchange using the queue name as the binding key. So all you need to do to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found