wagslane / go-rabbitmq

A wrapper of streadway/amqp that provides reconnection logic and sane defaults
https://blog.boot.dev/golang/connecting-to-rabbitmq-in-golang-easy/
MIT License
772 stars 126 forks source link

Improve document regarding exchange #45

Closed lucaswxp closed 2 years ago

lucaswxp commented 2 years ago

So, I'm about 2 hours trying to figure it why my published messages weren't arriving on my consumer, and it turns out I should be using the queueName as routing-key for the publisher!

I only discovered this after looking up if the go-rabbitmq was creating an exchange for me, it turns out if left unspecified it binds to the default rabbitmq exchange:

The default exchange is a direct exchange with no name (empty string) pre-declared by the broker. It has one special property that makes it very useful for simple applications: every queue that is created is automatically bound to it with a routing key which is the same as the queue name.

https://www.rabbitmq.com/tutorials/amqp-concepts.html

So, the examples on README won't actually show a working pub-sub cycle that actually works, that is a little bit confusing.