Sunday, August 10, 2014

RabbitMQ Important Concepts

RabbitMQ some important concepts:

1. Channel: This channel is a virtual connection inside the “real” TCP connection, and it’s over the channel that you issue AMQP commands. Every channel has a unique ID assigned to it (your AMQP library of choice will handle remembering the ID for you). Whether you’re publishing a message, subscribing to a queue, or receiving a message, it’s all done over a channel.

2. Connection: a connection to a RabbitMQ server instance

3. Producers: Producers create messages and publish (send) them to a broker server (RabbitMQ).

4. Consumers: Consumers are just as simple. They attach to a broker server and subscribe to a queue. Think of a queue as a named mailbox.

5. What is the relationship between Channel and Queue? There is no direct relation between Channel and Queue. A Channel is used to send AMQP commands to the broker. This can be the creation of a queue or similar, but these concepts are not tied together.

6. What is the relationship between Queue and the Consumer Pool? Can multiple Consumers be subscribed to the same Queue? Can multiple Queues be consumed by the same Consumer? Or is the relationship 1:1?
It is also possible to attach the same Consumer to multiple Queues. You can understand Consumers as callbacks. These are called everytime a message arrives on a Queue the Consumer is bound to. For the case of the Java Client, each Consumers has a method handleDelivery(...), which represents the callback method. What you typically do is, subclass DefaultConsumer and override handleDelivery(...). Note: If you attach the same Consumer instance to multiple queues, this method will be called by different threads. So take care of synchronization if necessary.

No comments:

Post a Comment