In test and production environments I run RabbitMQ on Linux, but my development environment happens to be windows. I need to have a local instance of RabbitMQ. Since RabbitMQ supports Windows the setup is fairly straight forward, but there are some potential problems you can run into. This article is meant as a quick start to help get you up and running as soon as possible.
For this example I will be using the following versions:
Install Erlang
First thing to do is ensure the version of Erlang you are installing is compatible with the version of RabbitMQ you will be using. You can check the compatibility guide.
Download Erlang
Download Erlang from the main Erlang website. Note in this example we are using version 24.1
Run the Installer
Run the installer as Administrator, this is very important!!!
Create the Erlang Environment Variable
You will also need to create the ERLANG_HOME environment variable pointing to the root folder of where Erlang was installed.
I forgot to run the Erlang installer as Administrator, how do I fix it?
Installing as a non-administrator user leaves the .erlang.cookie in the wrong location. This makes it impossible to use rabbitmqctl.
Workarounds
You have two options to fix this problem:
- Uninstall Erlang and run the installer again as Administrator
- Move the .erlang.cookie to the correct location
- Copy the file .erlang.cookie manually from
- %SystemRoot% or %SystemRoot%\system32\config\systemprofile
- to %HOMEDRIVE%%HOMEPATH%
- Copy the file .erlang.cookie manually from
Install RabbitMQ
For reference, here is the link to the official RabbitMQ Installing on Windows instructions.
Download RabbitMQ from GitHub releases. Note in this example we are using version 3.10.5.
Run the installer as Administrator, this is extremely important!!!
Now you have successfully installed RabbitMQ. However, before we go any further you will want to install a very useful plugin called Management Plugin.
Enable Management Plugin
The Management Plugin for RabbitMQ enables a web interface you can use for managing your instance of RabbitMQ. This plugin is extremely useful and you will want it, especially in a development environment.
Open a PowerShell command prompt.
Set a variable called homedrive to be the root folder of your user account:
set homedrive=C:\users\<Username>
Go to the RabbitMQ sbin folder:
cd C:\Program Files\RabbitMQ Server\rabbitmq_server-3.10.5\sbin
Stop RabbitMQ:
rabbitmqctl.bat stop
Enable the plugin:
rabbitmq-plugins.bat enable rabbitmq_management
If successful you should now see the plugin in the list of enabled plugins:
rabbitmq-plugins.bat list
Start RabbitMQ:
rabbitmqctl.bat start
Login To Management Console
Go to Management Console webpage in a browser:
You should see a login prompt:
Login using the default guest user account (Note: This account ONLY works from localhost)
- Username: guest
- Password: guest
You should now see the Overview page.
If you get this far, then congratulations, everything is working fine!
Setup RabbitMQ for Client Connections
Now that we have RabbitMQ up and running, before we can connect to it from a client there is some setup you should do. Primarily creating a Virtual Host and a User Account.
Create a Virtual Host
A Virtual Host in RabbitMQ is kind of like a namespace. It allows you to have multiple applications connecting to a single instance/cluster of RabbitMQ while keeping your connections, exchanges, queues, separate for each application.
Go to Admin -> Virtual Hosts and add a new virtual host:
The new virtual host has now been added:
Create a User Account
Go to Admin -> Users and add a new user account. Also make sure to add the “administrator” tag if your user account is going to be used to create queues, etc.
The new user account has been created:
Add Virtual Host to User
Note that the new user account does not have access to any virtual hosts yet. So we will add our virtual host to our user account next.
From the Admin -> Users tab click on the username of the user we just created:
From the drop down select our virtual host and click the “Set Permissions” button:
If you go back to the Users tab you can see that your user account now has permissions to your virtual host:
You can now connect a client to this instance of RabbitMQ using your virtual host and user account!
Enable Feature Flags
Just so you are aware, RabbitMQ uses Feature Flags when adding new features. This is a great approach since it allows you to more easily do rolling upgrades when upgrading a RabbitMQ cluster. Since a number of Feature Flags are off by default, you may want to enable these flags in your development environment if you are going to be using them in production.
You can view feature flags from Admin -> Feature Flags:
As a side note, if you are curious to read more about Feature flags as a pattern for deploying new features in an application, the following article is a really good introduction to this strategy:
Summary
That is all. I hope these instructions helped you get your instance of RabbitMQ up and running!