Communication

Message Queues (MQ)

Description

Message queues provide an asynchronous communications protocol, meaning that the sender and receiver of the message do not need to interact with the message queue at the same time. Messages are stored on the queue until they are processed and deleted.

Where to use

  • Load leveling.
  • \n
  • Decoupling producers and consumers.
  • \n
  • Background processing.

Real World Example

An Image Upload service pushes a job to a RabbitMQ queue. A separate Worker service pulls the job and resizes the image.

Code Example

# Code Concept for Message Queues (MQ)\n# This pattern is architectural.\n\nclass Service:\n    def execute(self):\n        # Implementation logic\n        pass