Major Version Upgrade (Blue-Green Deployment)
RabbitMQ 3.12.x cannot be directly upgraded to 4.2.x through an in-place upgrade. You need to create a new 4.2.x instance and migrate data from the old instance. This document provides two migration approaches based on whether downtime is acceptable.
- Option 1: Drain & Migrate — If you can tolerate a brief service interruption, consume all messages first, then switch to the new instance. This is the simplest approach.
- Option 2: Blue-Green Upgrade — If you cannot tolerate downtime, use the Federation plugin to achieve a seamless migration with zero message loss.
TOC
Option 1: Drain & Migrate (Acceptable Downtime)Option 2: Blue-Green Upgrade (Zero Downtime)How It WorksPrerequisitesProcedureVerification ChecklistRollbackOption 1: Drain & Migrate (Acceptable Downtime)
This approach involves a brief service interruption. If your business can tolerate downtime, this is the most straightforward approach:
- Drain Messages: Stop all producers and wait for consumers to process all remaining messages. Ensure all queues are empty.
- Export Definitions: Export the definitions (exchanges, queues, bindings, users, vhosts) from the old 3.12.x instance.
- Create New Instance: Deploy a new RabbitMQ 4.2.x instance.
- Import Definitions: Import the definitions into the new 4.2.x instance.
- Switch Traffic: Update your application configurations to connect to the new instance and restart them.
- Decommission: Once everything is confirmed working, delete the old 3.12.x instance.
Option 2: Blue-Green Upgrade (Zero Downtime)
This approach uses the RabbitMQ Federation plugin to seamlessly transfer messages from the old instance (blue) to the new instance (green), without stopping producers or consumers. For more details, refer to the official Blue-Green Deployment guide.
How It Works
- Deploy a new 4.2.x instance (green) alongside the existing 3.12.x instance (blue).
- Import definitions from blue to green (exchanges, queues, bindings, users, etc.).
- Configure queue federation on the green cluster with an upstream pointing to blue.
- Migrate consumers to green — federation automatically pulls messages from blue to green.
- Drain remaining messages from blue.
- Migrate producers to green.
- Decommission the blue cluster.
Federated queues work on the principle that consumers connected to the green cluster will receive messages published to the blue cluster, as long as there are no local consumers on blue for those queues. Local consumers always take precedence.
Prerequisites
- The old RabbitMQ 3.12.x instance (blue) is healthy and in
Activestate. - The
rabbitmq_federationplugin is available in both instances.
Procedure
Step 1: Create a new 4.2.x instance (green cluster)
Wait for the green instance to become Active:
Step 2: Export definitions from blue and import into green
Verify definitions are imported correctly:
Step 3: Configure federation upstream on green cluster
Get the blue cluster's internal service address first:
Then get the blue cluster's credentials:
If your username or password contains special characters (like @, :, /), ensure they are URL-encoded in the connection URI below.
Configure the upstream on the green cluster pointing to blue:
Set a federation policy to match all queues:
In RabbitMQ, if multiple policies match a queue, only the one with the highest priority is applied. If your imported definitions already contain policies covering your queues, the blanket blue-federation policy above might not take effect (or it might overwrite existing rules if given higher priority).
In such cases, you should manually update the existing policies on the green cluster to include the "federation-upstream": "blue" key alongside their current definitions.
Verify federation status:
Step 4: Migrate consumers to the green cluster
Update your consumer application configurations to point to the green cluster's service address. At this point:
- Producers still publish to the blue cluster.
- Consumers read from the green cluster.
- Federation automatically pulls messages from blue to green.
You can get the green cluster's service address using the following command:
Verify messages are being fed through:
Before migrating consumers off the blue cluster, make sure the federation links on green are in running state. If a link is not running, messages will not be transferred.
Step 5: Drain messages from the blue cluster
Once all consumers have moved to green, federation will drain remaining messages from blue. Monitor progress:
For large backlogs, you can optionally use the Shovel plugin to accelerate draining:
Using shovel concurrently with federation will transfer messages in parallel, which may result in messages arriving out of order. If message ordering is critical, rely on federation alone.
Step 6: Migrate producers to the green cluster
Once the queues on blue are nearly empty:
-
Stop all producers.
-
Wait for the remaining messages to be fully drained via federation.
-
Verify all queues on blue are empty:
-
Update producer configurations to point to the green cluster and restart them.
Step 7: Clean up and decommission the blue cluster
Remove the federation policy and upstream configuration from green:
Delete the blue cluster:
Verification Checklist
Use the following checklist to verify each stage of the migration. Each step includes a CLI command that can be executed directly.
The commands below are designed to be executable step-by-step. Replace all placeholders (e.g. <namespace>, <blue-pod-0>) with actual values before running.
Rollback
If issues are encountered during the migration:
- Before consumer migration: Simply delete the green cluster. No impact on existing services.
- After consumer migration, before producer migration: Switch consumers back to the blue cluster. Delete the green cluster.
- After full migration: If the green cluster has issues, create a new 3.12.x instance, import definitions, and switch back. Note that messages produced to green after the switch will need to be drained back using shovel or federation in reverse.