NOTE

3.1 RabbitMQ Usage

RabbitMQ data flow and work modes using work queues and fanout, direct, and topic exchanges.

Message QueuesCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. Data Transfer Flow

The producer sends a message -> RabbitMQ’s exchange routes it to the corresponding queue through the routing key -> the consumer receives the message.

2. Work Modes

Code for sending a message:

void basicPublish(String exchange, String routingKey, BasicProperties props, byte[] body)
  • Work queue, with an empty exchange This mode sends the message to the QUEUE_NAME queue.
("",  "QUEUE_NAME", ...)
  • Publish-subscribe, fanout exchange This mode broadcasts all messages to queues bound to the fanout exchange.
("fanout",  "",  ...)
  • Publish-subscribe, direct exchange This mode routes messages according to conditions, sending part of the messages on the direct exchange to queue 1 and another part to queue 2.
("direct",  "routing_key",  ...)
  • Publish-subscribe, topic exchange, which is more fine-grained than direct. It sends part of the messages on the topic exchange to queue 1 and another part to queue 2. This mode routes messages according to conditions.
("topic",  "routing_key",  ...)

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub