Files I produced during the RabbitMQ classes of my Microservices Full Cycle 3.0 course.
In RabbitMQ, you can use the same TCP connection to receive and send messages. To do that, you just need to use two different channels inside the same TCP connection.
Examples using RabbitMQ Simulator
As both consumers are subscribed to the same queue, when one consumer get a message, the message is removed from the queue and the other consumer needs to wait for a new message to get it.
Note that when I create the new queue and connect it to the exchange setting the routing key as y, when I change the producer routing key to y, the messages only go to the queue y.
Note that the exchange in fanout mode sends the messages to all queues connected to them. Also, as I created a queue without anyone consuming it's messages, it started to accumulate the messages and as soon as I created the consumer for it, the queue started to be emptied.
Note that the exchange in topic mode sends the messages to all connections that match a pattern.