The queue is like a listening port similar to a socket channel. Every consumer must need to have a unique queue name. For example user_created
, log_created
Exchange is like a postman for your message. Exchange is responsible for pushing messages to one or multiple queues based on exchange type.
- direct
- fanout
- topic
- header
Direct exchange refers to sending a message to a specific queue using a routing key. In exchange type direct
, multiple queues bind with exchange with a unique routing_key
. When we publish a message to Direct Exchange
, we must need to provide a routing_key as well to decide in which queue the message will go.
This exchange is intended to send messages to multiple queues simultaneously. Unlike the Direct exchange type, Fanout exchange binds with several queues without any routing_key
. So we don't need to provide any routing_key
while publishing a message to fanout exchange as it doesn't bind queues with any routing_key.