NOTE
3.1 RabbitMQ Usage
RabbitMQ producers send messages to an exchange, which routes them to queues using routing keys for consumers to receive. Code examples record that flow.
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. Messaging Patterns
Code for sending a message:
void basicPublish(String exchange, String routingKey, BasicProperties props, byte[] body)
- Work queue, with an empty exchange name
This mode sends the message to the
QUEUE_NAMEqueue.
("", "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 some messages on the direct exchange to queue 1 and others to queue 2. This mode routes messages according to conditions.
("topic", "routing_key", ...)
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub