Alireza Farokhi
2 min readMay 15, 2022

Message Queue and Advantages

What is Message Queue

A message queue is a form of asynchronous service-to-service communication used in server less and micro services architectures. The principle behind this is simple: a message is sent to the queue and stored on the queue, and one or more clients can retrieve and process that message. Message queues can be used to decouple heavyweight processing, to buffer or batch work, and to smooth spiky workloads.

Advantages of Message Queue

Imagine we have online concert ticket reservation and we want to send an email or text to user after ticket is reserved. We have 2 services and message queue as part of our system like bellow:

Reservation Service can perform some task and put a message onto a queue (or message bus there are messaging patterns other than queues). Notifications Service can read the message from that bus and perform a task.

Reservation Service, process availability and other things then reserve ticket(s), then sends a message to message queue. on the other side Notifications Service get message and inform user.

  • One of the advantages that message queue brings is covering Solid Separation of Concerns principle Reservation Service has absolutely no dependency or even knowledge that Notifications Service exists and vice versa. In fact, we could replace Reservation Service with another process, or several processes, without affecting Notifications Service in the slightest.
  • The second advantage is resilience. Let’s imagine that Notifications Service fails: if Reservation Service were calling Notifications Service, then that would cause both processes to fail; however, since all Reservation Service is doing is writing to a queue, the messages will simply remain in the queue until such time as they are picked up.
  • Other advantage is system is able to cope with sudden fluctuations in traffic

more detail:

linked in:

https://www.linkedin.com/in/alirezafarokhi/

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Alireza Farokhi
Alireza Farokhi

No responses yet

Write a response