What is Message Queue(MQ)? — Concept

Jinwon Park
1 min readOct 4, 2021

--

Message Queue allows asynchronous communication between applications.

Use case: Let’s say you run an e-commerce platform. Each merchandise info(ex. operation hours) is cached, as it is a data that is not changed often.

Also, you provide admin page for the merchandise owners. Some merchandise owner might want to change operation hours.

Running on separate application(A for e-commerce platform and B for merchandise admin page), cached merchandise info does change even if merchandise owner changes it in the admin page.

This is a case where MQ can play a crucial part.

MQ can simply notify to the application A whenever merchandise info is changed in application B.

Application B can publish message to invalidate cache in application A. Application A can consume message and invalidate merchandise info, so that new cache will be set.

Message Queue consists of publishers(senders) and consumers(receivers), and message queue service acts as a message broker.

Example above is one of the many use cases where MQ can be useful.

So, this got me thinking, why not use http request instead of MQ?

  • MQ is asynchronous, meaning it won’t block the client request.
  • It scales better over time. What if there are millions of store owners requesting a service hour change? — if the server is at maximum capacity, http request will fail, and the process will not be done. MQ will assure the delivery, waiting for the server to open up for task.

More detailed use case with code example will be available using RabbitMQ.

--

--