Message Queues

Message Queues

Synchronous Communication

Synchronous communication means data or information is shared between the services in real time. When you're communicating synchronously with someone, virtually or physically, you expect a response from the person as soon as you send them something. Examples of synchronous communication are:

  • Phone Conversations or Video Calls
  • Meetings
  • Webinars
  • Casual coffee chats

Asynchronous Communication

Asynchronous communication, as the name suggests, is the opposite of synchronized communication. It means data or information is shared independent of time, i.e., you don't expect an immediate response. It allows people to take some time before responding to each message. Examples of asynchronous communication are:

  • Email
  • Text messages
  • Recorded video or voice messages
  • Project management tools
  • Assigned tasks and comments in the documents

sync.gif

What are message queues?

Let's talk about the message queue, A message queue is a form of asynchronous service-to-service communication used in micro-services or server-less architectures. Messages are stored in the queue until they are processed and deleted.

ms.gif

Messages are short pieces of data that tell us what task has to be done, just like the message that we send to a friend to get the cake or request that they do something. So the ones that create the message or make a request to the queues are called "producers." and the ones that carry out the messages from the queue are called "consumers."

messagequeue.png

Messages are placed in a queue. This enables messages to wait until the consumers can process them. If there is any problem processing the messages, the messages in the queue are not lost. Each message is processed only once by the single consumer.

Some advantages of the message queue are:

  • Handle a lot of requests
  • Consumers are scalable, i.e., you can increase or decrease the number of consumers with respect to the number of messages from the producers.
  • For some reason, if the consumers are not running, the messages are saved in the queue, so they are not lost. And the consumers can pick the message from the queue once it's up and running.

Some examples of Queue on complex system are SQS(Simple Queue Service), Kafka, RabbitMQ, etc.

WhatsApp Image 2022-02-09 at 23.12.png