Back to list
Lv.3

Message Queue

Message Queue

A system that temporarily lines up requests sent between programs and delivers them in order.

In Simple Terms

A message queue is a go-between that holds requests sent from one program and passes them to another program in order. By putting a storage spot between the program that sends requests and the program that does the work, the sender can move on to its next task without waiting, even if the other side is busy. For example, it's used to send a confirmation email behind the scenes after an online order, or to work through heavy jobs like image processing one at a time.

Behind the Name

The name describes exactly how it works. Each request or piece of data that one program sends to another is a "message", and those messages wait in a "queue", the same kind of line you see at a store checkout. Just like at the register, messages are taken out one at a time, starting from the front of the line. It's sometimes shortened to MQ.

Take a Closer Look!

A message queue is a system that temporarily holds requests and data exchanged between programs, then hands them over in order.
Instead of the sender and the receiver connecting directly and working at the same time, they exchange data through a dedicated storage spot placed between them.

For example, when you press the order button on an online store, lots of things happen behind the scenes, like checking stock and sending a confirmation email.
If the site tried to finish all of that on the spot, you'd have to stare at the screen until everything was done.
With a message queue, the program that receives your order just drops a request like "send the email" into the storage spot and immediately moves on.
Another program then picks up the requests one at a time from the front of the line, so the screen doesn't keep you waiting, and even if traffic suddenly spikes, the requests still get worked through in order.

Also, even if the receiving program stops for a moment, the requests themselves stay safe inside the message queue, so work can pick up right where it left off after the program recovers.
Think of the order-ticket rack in a restaurant kitchen: the server clips a ticket onto the rack, and the cooks make the dishes in order at their own pace.
Message queues are widely used whenever slow jobs need to be done reliably behind the scenes, such as sending notifications, processing images, or crunching large amounts of data.