Queues and Topics
In this section, we will take a look at Queues and Topics.
Queue:
In the context of messaging, a Queue allows point to point communication between producers and consumers in an asynchronous manner. Following is an execution path for a Queue:
- The producer publishes the message to an exchange
- The exchange would place the message on a Queue
- A consumer which has subscribed to read from the queue would read the message. Once the consumer reads the message from the queue, the message will be removed from the queue.
- The consumer would acknowledge the receipt of the message.
Topic:
In the context of messaging, a Topic allows for Publish/Subscribe model of communication, where a producer would place the message on a Topic. One or more consumers can subscribe to the topic and the message would be broadcasted to all the consumers who have subscribed to that topic. In the above diagram, we can see that publishers A and B place messages A and B respectively on the topic and the topic broadcasts both of these messages to each of the subscribers (C and D) respectively.
Reference Implementations:
A lot of commercial and open source vendors provide Queue/Topic implementations like Rabbit MQ, Active MQ, TIBCO.