From the course: Spring: Messaging with JMS

Understanding message queues and servers - Spring Tutorial

From the course: Spring: Messaging with JMS

Start my 1-month free trial

Understanding message queues and servers

- [Instructor] What is a message queue? A message queue is a collection of messages that are grouped on a server or a MOM. We generally call these MQ servers. The message queues retain the message until a consumer is available to retrieve them. Message queues retrieved are pulled in the order they are received. We call this FIFO, or first-in-first-out order. Message queues can have multiple consumers but, and this is important to remember, for a message on a queue, it can only have one consumer. This guarantees that the message is processed only one time. This is why we call queues a point-to-point model domain design. Topics on the other hand, can have multiple consumers, who have all subscribed to the same topic. Order delivery is not the same as queues and so there is no guarantee of order delivery. Similarly, a message on a topic could, and most likely will be processed multiple times and since multiple consumers are subscribed to the topic. It's important to remember that consumers subscribed to a topic on an MQ server must be active when the message is published to the topic, in order to access it, unless the subscription is a durable subscription. This is why we call this domain design pub/sub. With all that said, let's define our course project a bit more. What we'll be creating is an online bookstore. Our books are stored in a warehouse and the bookstore will place the orders to the warehouse for one or more books. The MOM for this project will be an Apache ActiveMQ. An ActiveMQ instance will sit between our bookstore app and the warehouse app. Both apps will act as consumers and publishers to either a queue or a topic. Our message queue on the ActiveMQ instance will be used for strictly publishing book order requests for a particular book. The warehouse app will be our consumer reading messages off the message queue in FIFO order processing. Once a book order request is processed, the warehouse app will publish to a book order process queue of those book orders as to whether they are completed, as well as published to a topic alerting changes to inventory. This topic will be called book inventory topic and will have a durable subscription to this topic, where after consuming will update possibly a local database inventory table.

Contents