Amazon MQ
Learn how to set up message brokers in the cloud using Amazon MQ and the types of brokers it supports.
We'll cover the following
Message brokers are middleware components that enable communication between application components and services using various programming languages, messaging protocols, and operating systems. Solution architects can use Amazon MQ, a message broker service provided by AWS, to set up their message brokers in the cloud.
Amazon MQ currently supports Apache ActiveMQ and RabbitMQ brokers. We can integrate this service with our existing applications eradicating the need of creating, managing, and operating our own messaging system.
Brokers in Amazon MQ
In Amazon MQ, broker instances are created, and are considered as the building blocks of Amazon MQ. A broker instance is a running instance environment of a message broker. A broker instance type includes the instance class and instance size; for example, in mq.t2.micro
, the t2
is the instance class, whereas micro
is the instance size. Following are the types of broker deployment modes in Amazon MQ:
Single-instance brokers: These brokers are deployed in only one Availability Zone. These brokers are usually used in applications that have a low message throughput.
Active/Standby brokers: This method is only available for ActiveMQ brokers. In this deployment method, two brokers are deployed in two different Availability Zones, providing us with a highly available infrastructure. In this method, one broker is always in a passive state, ready to take over in case the other broker fails. These brokers are used in critical applications where high availability is extremely crucial.
Cluster deployment: This method is only available for RabbitMQ brokers. In this method, three broker nodes are created, and traffic is distributed among them by using a Network Load Balancer.
The following diagram illustrates how different brokers work:
Cross-region data replication
Amazon MQ for ActiveMQ offers cross-region data replication. Here, the data from the primary broker is replicated into the replica broker available in some other AWS Regions. In case the primary broker fails due to any reason, the replica broker is upgraded to the primary broker and the former primary broker becomes the replica broker once it becomes available.
We do have the option of converting a replica broker into a primary broker ourselves by initiating a switchover or a failover. In a switchover, there may be a point in time where neither broker is available for client connections. However, in a failover, Amazon MQ makes sure that at least one broker is available all the time, and the replica broker becomes available immediately without waiting for any replication data to be synchronized.
Amazon SQS, SNS, and MQ
Amazon SQS, SNS, and MQ are all messaging services that are highly scalable and can be easily integrated with our applications. The main differences between these three services are given below:
Amazon SQS is a message queuing service that uses queues to store messages sent by a producer. These messages are then retrieved and processed by the consumers of the queue whenever the consumers are available.
Amazon SNS is a publish-subscribe service that acts as a message router and sends the messages it receives from a publisher to its subscriber endpoints. If a subscriber is not available to receive a message when it is published, the message is not stored for later retrieval.
Amazon MQ is a message broker service compatible with protocols such as MQTT and AMQP. It is recommended to use Amazon MQ to migrate existing applications that use message brokers to the cloud.
Pricing in Amazon MQ
In Amazon MQ, we are only charged for the time our messages broker instances are in the running state, the storage we use, and a monthly data transfer fee. There are varying fees for different instance sizes and classes.
Get hands-on with 1300+ tech skills courses.