Skip to main content
Matrix42 Self-Service Help Center

Enterprise Service Bus

RabbitMQ Server Upgrade

Before you start

  • Do not use the automated RabbitMQ installer from Matrix42 Marketplace to upgrade your RabbitMQ server. This will reset your installation to default and configured users and other custom settings will be lost.
  • Download the installation packages directly to your RabbitMQ host or copy the installation packages after downloading them from your client.

Check your current versions

  • Open your RabbitMQ management UI at http://localhost:15672
  • Login with your Username and Password
  • Review your RabbitMQ and Erlang version displayed in the header of the page

clipboard_e90a1a65b654cbb4bb9ddc0909694b6e2.png

Upgradability and Binaries Download

Manual Download (recommended)

Once the packages have been downloaded, there should be two installation packages like:

  • otp_win64_24.3.4.8.exe
  • rabbitmq-server-3.9.27.exe

PowerShell Download (optional)

You can use the following PowerShell script to automate the process of downloading the software.

Please note that the URLs and version numbers in the script may be out of date. Review the website for the latest version.

# Download Erlang OTP
$erlangUrl = "https://github.com/erlang/otp/releases/download/OTP-24.3.4.8/otp_win64_24.3.4.8.exe"
$erlangFile = "otp_win64_24.3.4.8.exe"
Invoke-WebRequest -Uri $erlangUrl -OutFile $erlangFile

# Download RabbitMQ Server
$rabbitUrl = "https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.9.27/rabbitmq-server-3.9.27.exe"
$rabbitFile = "rabbitmq-server-3.9.27.exe"
Invoke-WebRequest -Uri $rabbitUrl -OutFile $rabbitFile

You will find the downloaded files into your user profile, e.g. under C:\Users\vvalentine 

Backup

When upgrading a RabbitMQ Server installation on a Windows Server host, it's important to first backup your current configuration files as well as the definitions before proceeding with the upgrade. The default config file location vary between and operating systems and packages. It may also be that your RabbitMQ instance does not have any config files. In this case you can skip the two for backup and restore of the config files.  Please refer to the following link for additional information: How to Find Config File Location

Backup Config Files

  • Open PowerShell as an Administrator
  • Navigate to your RabbitMQ folder, e.g. C:\Program Files\RabbitMQ Server\rabbitmq_server-\3.9.5\sbin
  • Now execute the following command: 
.\rabbitmq-diagnostics status
  • Locate the Config files section that would look like this:
Config files

* /etc/rabbitmq/advanced.config
* /etc/rabbitmq/rabbitmq.conf
  • Navigate to the path(s) and copy your config files to a different location, e.g into your user profile (C:\Users\vvalentine)
  • Keep the paths in mind or note the paths down as you will need them later for restoring the files

The path to the config files is also visible in the management UI in the Overview tab > Nodes

Backup Definitions

  • To create a backup of the definitions (queues and users) execute the following in a PowerShell command line: 
.\rabbitmqctl.bat export_definitions $env:USERPROFILE\rabbitmq.definitions.json​

You will find the downloaded files again in your user profile, e.g. under C:\Users\vvalentine.

Exporting and importing definitions is also available in the management UI in the Overview tab. 

Backup Messages (optional)

Skip the export and later the import of messages as you like, they are considered disposable and if there is no load at the time of the update couple messages get lost, which is fine. To create a backup of all current messages, make an export using the PowerShell script below which is utilizing the RabbitMQ Managment REST API. Replace the username, password, and virtual host ($baseUrl/queues/matrix42) with your current values.

To learn more about options to create and to restore backups, please consider studying the RabbitMQ documentation.

$username = "rabbitmq" 
$password = "Password" 
$baseUrl = "http://localhost:15672/api" 

# Get all queues 
$queues = (Invoke-RestMethod -Uri "$baseUrl/queues" -Credential (New-Object System.Management.Automation.PSCredential($username, (ConvertTo-SecureString $password -AsPlainText -Force)))) 

# Iterate through all queues 
foreach($queue in $queues)
{
    # Get all messages in the queue
    $messages = (Invoke-RestMethod -Method POST -Body '{"count":100000,"ackmode":"ack_requeue_true","encoding":"auto","truncate":5000000}' -Uri "$baseUrl/queues/matrix42/$($queue.name)/get" -Credential (New-Object System.Management.Automation.PSCredential($username, (ConvertTo-SecureString $password -AsPlainText -Force)))) 
    $messages | ConvertTo-Json -Depth 10 | Out-File -FilePath "$env:USERPROFILE\queue_$($queue.name)_messages.json" -Encoding utf8 
    Write-Host "Exported $count messages from queue $($queue.name)"
}

You will find the backup files in a *.json format in your user profile, e.g. under C:\Users\vvalentine  

Execute Upgrade

Stop RabbitMQ Server

  • Run the following command to stop the RabbitMQ node and service on the host:
.\rabbitmqctl.bat shutdown

Upgrade Erlang

  • Run the downloaded Erlang installer, e.g. otp_win64_24.3.4.8.exe
  • Press Next (2x) and Install
  • Wait until the installation is finished and press close
  • Update the Environment Variable
    • Open Control Panel > System > Advanced system settings > Environment Variables
    • Locate the ERLANG_HOME variable and and check that it matches the current installation path (e.g. C:\Program Files\Erlang OTP)
    • In case you need to adjust the variable, press edit and proceed with Browse Directory

In case you get prompted for a reboot, skip the request until everything is installed

Upgrade RabbitMQ

Before starting with the RabbitMQ upgrade, close all explorer windows and command line prompts that access current RabbitMQ directory

  • Run the downloaded RabbitMQ installer, e.g. rabbitmq-server-3.9.27.exe
  • Press OK to confirm to remove the previous version
  • Press Next and press Install
  • Wait until the installation is finished and press Next
  • Press Finish
  • Update the Environment Variable
    • Open Control Panel > System > Advanced system settings > Environment Variables
    • Locate the RABBITMQ_BASE variable and and check that it matches the current installation path (e.g. C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.27)
    • In case you need to adjust the variable, press edit and  proceed with Browse Directory
  • Reboot your server

Restore

After the upgrade, you can restore your configuration by first stopping and removing the RabbitMQ service, copying the backup file to the directory of the new installation and finally installing and starting the RabbitMQ service. 

Restore Config Files

  • Open PowerShell as an Administrator
  • Navigate to your updated RabbitMQ folder, e.g. C:\Program Files\RabbitMQ Server\rabbitmq_server-\3.9.27\sbin
  • Now execute the following commands and take actions step by step:
.\rabbitmq-service stop
.\rabbitmq-service remove
  • Now copy your config files back to the path(s) locations
.\rabbitmq-service install
.\rabbitmq-service start
  • Enable Management UI
.\rabbitmq-plugins enable rabbitmq_management

Restore Definitions

  • Import Definitions (attention: PowerShell syntax is used here)
.\rabbitmqctl import_definitions $env:USERPROFILE\rabbitmq.definitions.json

In case you get a bad argument that file does not exist, copy the rabbitmq.definitions.json to your current sbin folder of RabbitMQ and execute the command without $env:USERPROFILE or use the Import Definition action in the management UI from the Overview tab. 

Restore Messages

Skip the import of messages as you like, they are considered disposable and if there is no load at the time of the update couple messages get lost, which is fine.

  • Import Messages using the PowerShell script below:
$username = "vvalentine" 
$password = "Matrix42" 
$baseUrl = "http://localhost:15672/api" 

# Get all queues
$queues = (Invoke-RestMethod -Uri "$baseUrl/queues" -Credential (New-Object System.Management.Automation.PSCredential($username, (ConvertTo-SecureString $password -AsPlainText -Force))))

# Iterate through all queues
foreach($queue in $queues)
{
    $messages = Get-Content "$env:USERPROFILE\queue_$($queue.name)_messages.json" | ConvertFrom-Json
    foreach($message in $messages)
    {
        Invoke-RestMethod -Method Post -Uri "$baseUrl/exchanges/matrix42/$($message.exchange)/publish" -Body ($message | ConvertTo-Json -Depth 10) -Credential (New-Object System.Management.Automation.PSCredential($username, (ConvertTo-SecureString $password -AsPlainText -Force))) | Out-Null    
    }
}

Review Exchanges and Queues

  • Open your management console at http://localhost:15672
  • Navigate to Exchanges and review if everything is present
  • Navigate to Queues and review if everything is present

When opening Queues and selecting one Queue, you might get an Reference Error. In this case clear your browser cache. 

Check the Status

  • Now run the following commands to verify the status:
.\rabbitmq-diagnostics ping​
.\rabbitmq-diagnostics status​
  • Was this article helpful?