MESSAGE TYPES IN RABBITMQ

Direct queues

This message type sends a message directly from the sender to the receiver. In other words, there is a one-to-one relationship. You can have many queues, of course, but they all still only have one receiver. Think of it like two persons talking to each other.

Fanout queue

A fanout queue distributes the message to everybody that subscribes to the queue. If you subscribe, you get the message.

This works like a speaker talking to an audience. One speaker, everybody listens.

Topic queue

The Topic queue is one of two queues where you set up a filter that limits what is received. The other one is the Header queue. A Topic is a series of words separated with dots, using the pattern {word}.{word}…{word}.

It is possible to use wildcards to make the subscription a little bit more general.
* means ‘any word’ (singular)
# means ‘any words’ (plural)

The receiver sets up a word-pattern that it subscribes to. Have a look at these examples.

Publisher routing key
homeelectronics.music.salesHome electronics division, music department, sales.
homeelectronics.appliances.serviceHome electronics division, appliances department, service errands.
office.supplies.salesOffice division, supplies department, sales.
Subscriber filter
homeelectronics.*.salesReceives sales from the home electronics division, no matter what department.
#.salesReceives all sales, no matter the division or department.
homeelectronics.music.sales    Receives only sales for the music department in the home electronics division

Header queue

The Header queue is one of two queues where you set up a filter that limits what is received. The other one is the Topic queue. A Header queue uses a set of key-value-pairs to filter the messages. They are stored in the header of the message, hence the name.

Like it? Share it!

Leave a Reply

Your email address will not be published. Required fields are marked *