# MQ

Why MQ Came in Place&#x20;

<figure><img src="https://1856860631-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsNc001Xcz63mWjGXymkd%2Fuploads%2FWQ9O9YMrdAd0X8uo4t3P%2Fimage.png?alt=media&#x26;token=fb68b1cd-1702-4c9b-ae3d-e4a0a289e662" alt=""><figcaption></figcaption></figure>

AWS MQ is a managed message broker service.\
A message broker is like a post office for computers: it helps different applications or services send messages to each other reliably.

Think of it like this:

* App A wants to tell App B: “Order placed.”
* AWS MQ ensures that message gets delivered safely and in order, even if App B is busy or temporarily offline.

Why use AWS MQ?

* Managed Service: AWS handles setup, maintenance, scaling, and patches. You don’t have to manage servers.
* Reliable Messaging: Guarantees messages are delivered once and in order.
* Compatibility: Supports standard messaging protocols like ActiveMQ and RabbitMQ, so apps don’t need major changes.
* Decoupling: Apps don’t communicate directly. They send messages to MQ, which delivers them—making systems more stable.

#### **Simple Example**

* Online Store:
  * Customer places order → message sent to MQ → inventory service receives message → updates stock → shipping service receives same message → ships order.
* Even if inventory or shipping is temporarily down, MQ keeps the message safe until the service is ready.

<figure><img src="https://1856860631-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsNc001Xcz63mWjGXymkd%2Fuploads%2FvAY6O9yOF8SbwaiZIWbB%2Fimage.png?alt=media&#x26;token=88c4cb30-2fdb-40cd-aee7-0ff8e85c91bd" alt=""><figcaption></figcaption></figure>

SNS architecture

<figure><img src="https://1856860631-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsNc001Xcz63mWjGXymkd%2Fuploads%2FhECDtJofBQxrFxyxqBis%2Fimage.png?alt=media&#x26;token=90364531-9f63-4f62-a408-c9702283901a" alt=""><figcaption></figcaption></figure>

SQS architecture

<figure><img src="https://1856860631-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsNc001Xcz63mWjGXymkd%2Fuploads%2FwfuDsBre0RpGObpOmciy%2Fimage.png?alt=media&#x26;token=8b277976-8114-41a8-8370-b66d0a76989d" alt=""><figcaption></figcaption></figure>

MQ architecture

<figure><img src="https://1856860631-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsNc001Xcz63mWjGXymkd%2Fuploads%2FbPvA0ADJ1MKDorJS4jEY%2Fimage.png?alt=media&#x26;token=aacb3a4e-17aa-454d-9deb-0394f35ec373" alt=""><figcaption></figcaption></figure>

Default you should use SNS SQS

<figure><img src="https://1856860631-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsNc001Xcz63mWjGXymkd%2Fuploads%2FdUPBGjA0B6rmOfcDj6xL%2Fimage.png?alt=media&#x26;token=32236c90-8ddf-4d0f-853d-eab9cf2efbf9" alt=""><figcaption></figcaption></figure>
