In message queue systems (like RabbitMQ, AWS SQS, Apache Kafka, etc.), the terms queue consumer, queue publisher, and queue topology refer to core concepts related to how messages are exchanged between systems in a decoupled manner.
🔸1. Queue Publisher (Producer)
Definition:
A queue publisher (also called a producer) is an application or service that creates and sends messages to a queue.
Responsibilities:
Generates messages (data/events/tasks).
Publishes messages to a message queue or exchange.
Often unaware of who (or if anyone) will consume the message.
Example:
// PHP example using RabbitMQ
$channel->basic_publish($msg, 'exchange_name', 'routing_key');
🔸2. Queue Consumer
Definition:
A queue consumer is an application or service that retrieves and processes messages from a queue.
Responsibilities:
Listens to a queue or subscribes to a topic.
Receives and processes messages.
May acknowledge the message after processing (important in systems like RabbitMQ).
Example:
$callback = function($msg) {
echo 'Received: ', $msg->body, "\n";
};
$channel->basic
🔸 3. Queue Topology
Definition:
Queue topology refers to the architecture/configuration of the messaging system, including how queues, exchanges (or topics), and bindings are set up.
Components may include:
Queues: Buffers that store messages.
Exchanges/Topics: Directs messages to appropriate queues (based on routing keys, fanout, etc.).
Bindings: Rules connecting exchanges to queues.
Routing keys: Used to decide how messages are routed.
Dead Letter Queues (DLQ): Handle failed message processing.
Example (RabbitMQ topology):
An exchange of type "direct" is set up.
Two queues bound to the exchange with routing keys.
One producer sends messages with routing key order.created.
Consumers read from queues based on their routing key match._consume('queue_name', '', false, true, false, false, $callback);
Producer --> [Exchange] --> [Queue A] --> Consumer A
--> [Queue B] --> Consumer B
| Term | Role |
|---|---|
| Queue Publisher | Sends messages to a queue or exchange |
| Queue Consumer | Listens to and processes messages from a queue |
| Queue Topology | Configuration of queues, exchanges, bindings, routing, etc. |