

# Quorum queues for RabbitMQ on Amazon MQ
<a name="quorum-queues"></a>

 Quorum queues are a replicated queue type made up of a leader (primary replica) and followers (other replicas). If the leader becomes unavailable, quorum queues uses the [Raft](https://raft.github.io/) consensus algorithm to elect a new leader node by majority of votes, and the previous leader is demoted to a follower node in the same cluster. The remaining followers continue replicating as before. Because each node is in a different availability zone, if one node is temporarily unavailable, message delivery continues with the newly elected leader replica in another availability zone. 

 Quorum queues are useful for handling poison messages, which occur when a message fails and is requeued multiple times. 

You should not use quorum queues if you:
+  use transient queues 
+  have long queue backlogs 
+  prioritize low latency 

 To declare a quorum queue, set the header `x-queue-type` to `quorum`. 

**Topics**
+ [Migrating from classic queues to quorum queues on Amazon MQ for RabbitMQ](quorum-queues-migration.md)
+ [Policy configurations for quorum queues for Amazon MQ for RabbitMQ](quorum-queues-policy-configurations.md)
+ [Best practices for quorum queues for Amazon MQ for RabbitMQ](quorum-queues-best-practices.md)

# Migrating from classic queues to quorum queues on Amazon MQ for RabbitMQ
<a name="quorum-queues-migration"></a>

You can migrate your classic mirrored queues to quorum queues on Amazon MQ brokers on version 3.13 or above by creating a new virtual host on the same cluster, or by migrating in place. 

## Option 1: Migrating from classic mirrored queues to quorum queues with a new virtual host
<a name="migrating-quorum-queues-with-vhost"></a>

 You can migrate your classic mirrored queues to quorum queues on Amazon MQ brokers on version 3.13 or above by creating a new virtual host on the same cluster. 

1. In your existing cluster, create a new virtual host (vhost) with the default queue type as quorum.

1. Create the [Federation plugin](rabbitmq-basic-elements-plugins.md#rabbitmq-federation-plugin) from the new vhost with the URI pointing to the old vhost using classic mirrored queues.

1. Using `rabbitmqadmin`, export the definitions from the old vhost to a new file. You must make changes to the schema file so it is compatible with quorum queues. For the full list of changes you need to make to the file, see [Moving definitions](https://www.rabbitmq.com/blog/2023/03/02/quorum-queues-migration#moving-definitions) in the RabbitMQ quorum queues documentation. After applying the necessary changes to the file, reimport the definitions to the new vhost. 

1.  Create a new policy in the new vhost. For recommendations on Amazon MQ policy configurations for quorum queues, see [Policy configurations for quorum queues for Amazon MQ for RabbitMQ](quorum-queues-policy-configurations.md) . Then, start the Federation you created earlier from the old vhost to the new vhost. 

1.  Point consumers and producers to the new vhost.

1. Configure the Shovel plug in to move any remaining messages. Once a queue is empty, delete the Shovel.

## Migrating from classic mirrored queues to quorum queues in place
<a name="migrating-quorum-queues-in-place"></a>

 You can migrate your classic mirrored queues to quorum queues on Amazon MQ brokers on version 3.13 or above by migrating in place. 

1. Stop the consumers and producers.

1. Create a new temporary quorum queue.

1. Configure the Shovel plug in to move any messages from the old classic mirrored queue to the new temporary quorum queue. After all messages are moved to the temporary quorum queue, delete the Shovel.

1. Delete the source classic mirrored queue. Then, recreate a quorum queue with the same name and bindings as the source classic mirrored queue.

1. Create a new Shovel to move the messages from the temporary quorum queue to the new quorum queue.

# Policy configurations for quorum queues for Amazon MQ for RabbitMQ
<a name="quorum-queues-policy-configurations"></a>

You can add specific policy configurations to quorum queues for your RabbitMQ broker on Amazon MQ.

 When you create a policy for quorum queues, you must do the following: 
+ Remove all policy attributes that start with `ha`, such as `ha-mode`, `ha-params`, `ha-sync-mode`, `ha-sync-batch-size`, `ha-promote-on-shutdown`, and `ha-promote-on-failure`. 
+ Remove `queue-mode`.
+  Change overflow when it is set to `reject-publish-dlx` 

**Important**  
 Amazon MQ for RabbitMQ applies all or none of the attributes within a policy. You cannot create a policy that applies to both classic mirrored queues and quorum queues. If you want your policy to only apply to quorum queues, you must set `--apply-to` to `quorum_queues`. If you are using classic mirrored queues and quorum queues, you must create a separate policy with `--apply-to`:`classic_queues` as well as a quorum queues policy. 

You do not need to modify `AWS-DEFAULT` policies because they automatically adopt the new queue type in the “applies to” parameter. For more information on default policies for Amazon MQ for RabbitMQ, see [Configuring operator policies](configurable-values.md#configuring-operator-policies). 

# Best practices for quorum queues for Amazon MQ for RabbitMQ
<a name="quorum-queues-best-practices"></a>

We recommend using the following best practices to improve performance when working with quorum queues.

## Handling poison messages by setting a delivery limit
<a name="using-quorum-queues-delivery-limit"></a>

 Poison messages occur when a message fails and is redelivered multiple times. You can set a message delivery limit using the `delivery-limit` policy argument to drop messages that are redelivered multiple times. If a message is redelivered more times than the delivery limit allows, the message is then dropped and deleted by RabbitMQ. When you set a delivery limit, the message is requeued near the head of the queue. 

## Message priority for quorum queues
<a name="quorum-queues-message-priority"></a>

 Quorum queues do not have message priority. If you need message priority, you must create multiple quorum queues. For more information on prioritizing messages with multiple quorum queues, see [Message priority](https://www.rabbitmq.com/docs/quorum-queues#priorities) in the RabbitMQ documentation. 

## Using the default replication factor
<a name="using-quorum-queues-replication-factor"></a>

 Amazon MQ for RabbitMQ defaults to a replication factor of three (3) nodes for cluster brokers using quorum queues. If you make changes to `x-quorum-initial-group-size`, Amazon MQ will default again to the replication factor of 3. 