Designing Notification System with Message Queues
Tags: technology, architecture, gettingstarted, softwareengineering
Published: 2021-02-15 16:11:36

---
title: Designing Notification System with Message Queues
published: true
date: 2021-02-15 15:29:34 UTC
tags: technology,softwarearchitecture,gettingstarted,softwareengineering
canonical_url: https://towardsdatascience.com/designing-notification-system-with-message-queues-c30a2c9046de
---

[![](https://cdn-images-1.medium.com/max/2600/0*XKXmKrE1pwboGmaw)](https://towardsdatascience.com/designing-notification-system-with-message-queues-c30a2c9046de?source=rss-577e2119c7f2------2)

###What is Message Queue?
From the name itself, you can understand it is a queue. But it’s a particular type of queue. It routes messages from the sender to the receiver.

It is a queue; it follows the FIFO (First In First Out) policy. It means the message that is sent first will be delivered first. In some cases, we can add priority to a message, which will make it a priority queue.

So, where do we use a message queue? Say we are designing an email server. The sender sends an email, but the receiver is offline. The mail server needs to temporarily store the mail until the recipient comes online and gets the message.

Message queues can also be used for implementing notification systems. Message queues also allow us to run background processes, tasks.

###Properties Of A Message Queue
Message queues are asynchronous in style. Asynchronous behavior allows the components(sender and receiver) to communicate with each other in the background.

An important property of message queues is that they give temporary storage for storing messages until they are processed & received by the receiver. This is the property that makes the message queue an important component while designing a system.
We can add priority to the messages in case of the requirement of the system. 

Other important message queuing properties include message acknowledgments when a message is received successfully, retrying for failed messages in case of failure scenarios.

We now need to look into a popular messaging model widely used in the industry, the publish-subscribe message routing model.

###Publish-Subscribe Pattern
A Publish-Subscribe model is where many consumers receive the same message sent from a single or many sources.

Current days, we often subscribe to various topics on websites for being notified of the new updates on any particular interest. Be it from Facebook groups, Livescore for games, etc. We will discuss pub-sub in another article. For now, we should know, message queues have components that push the messages to the queues based on the message type and the rules which are set.
The exchange component will push the message to the queue, and the consumers will receive the message. The relationship between exchange and the message queue is known as Binding.

Facebook newsfeed notification system with the message queue
In the latter part of this article, we will discuss how notification systems and real-time feeds are implemented using message queues.

For more detailed implementation, check [this link](https://towardsdatascience.com/designing-notification-system-with-message-queues-c30a2c9046de?sk=937b77db768eacc200af603914738a7f)

[The main article is published in Towards Data Science »](https://towardsdatascience.com/designing-notification-system-with-message-queues-c30a2c9046de?source=rss-577e2119c7f2------2)