Using RabbitMQ in a messenger app architecture
Tags: architecture, discuss, appdevelopment
Published: 2019-07-29 16:47:12

Mobile messengers have become very popular recently. At the moment, there are plenty of mobile messengers like Viber, WhatsApp, Skype, Telegram, each having its pros and cons.

In today's competitive market, an application must have a perfect design, be easily scalable, and be able to support heavy loads when necessary. 

What's more, it must provide a high-security level so that users will be sure that their personal data are in safe hands. To ensure security, you can integrate <a href="https://smartym.pro/blog/mobile-app-security-using-end2end-encryption-for-protecting-mobile-messengers/">end-to-end encryption</a> which is already used by many famous messengers.

Building such functionality is a real challenge since it requires not only a lot of time for development and testing, and high developers' qualification, but also integration with reliable platforms for message delivery.

In our case, the best way was to use an open-source message broker <a href="https://github.com/rabbitmq">RabbitMQ</a> which supports different protocols of message delivery and has plenty of client libraries allowing to integrate it with popular mobile platforms (iOS, Android).

This solution let us pay more attention to architecture and business logic development and ensure stable work of message delivery and easy scaling.


<b>RabbitMQ enables to easily implement the following features:</b>

- group chats
- message delivery check
- receiving a message from the user while offline
- receiving a message on all client applications at the same time (iOS, Android)
- preventing unnecessary messages sending
- message delivery optimization in case of disconnection from RabbitMQ, e.g. during Internet cut-off


At the same time, the software engineering process always has some challenges. For instance, when making a mobile solution, our team had to implement communication of RabbitMQ with the server-side and communication with an Android app using the <a href="https://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol">AMQP protocol</a>.

In the beginning, we planned to use AMQP Objective-C wrapper for a librabbitmq-c library for iOS. But it turned out that it had many latent problems – this issue was solved by replacing AMQP protocol with <a href="https://github.com/jmesnil/MQTTKit">MQTT</a>. One should note that we didn’t have such difficulties with the client library on Android.

In addition, we had a challenge of correct message delivery configuration, which needed the right choice of Quality of service (QoS). As a consequence, we created a reliable system that supported heavy loads and their increase due to the expansion of the user base and user activity peaks.

The use of RabbitMQ in message application architecture helps easily solve a message delivery problem with the support of multi-user conversations and with several clients switched on.

Therefore, the RabbitMQ message broker is an effective solution for messenger development and implementation of many other IoT-based tasks. It completely solves the issue of communication with the application, which allows engineers to focus on implementing the app business logic.


Also, learn more about using the <a href="https://smartym.pro/blog/using-rabbitmq-message-broker-for-messenger-development-some-clues-for-developers/">RabbitMQ for creating messengers</a> and find out how to get started with RabbitMQ in its <a href="https://www.rabbitmq.com/getstarted.html">tutorial</a>.