﻿# RabbitMQ

> [HTML Version](rabbitmq.html)

The article describes the installation of RabbitMQ for Ubuntu Linux 20.04. You can also refer to the brief guide in the [official documentation](https://www.rabbitmq.com/install-debian.html).

It is recommended to install RabbitMQ in the same Kubernetes environment as the BRIX application. For more details on infrastructure organization options, refer to [Prepare BRIX On-Premises infrastructure](infrastructure-preparation.md).

RabbitMQ version 4.0 is not supported in the current version of BRIX. Check the supported RabbitMQ versions in the [System requirements for BRIX On-Premises](elma365-enterprise-on-premises.md#rabbit) article.

````
начало внимание

````
In this example, the virtual host name is **brix365vhost**, the user is **brix365user**, and the password is **SecretPassword**. When configuring, set this data according to the security policy in your organization.

````
конец внимание

````
Installation consists of three steps:

1. [Install RabbitMQ](#1rabbitmq).

2. [Configure RabbitMQ](#2rabbitmq).

3. [Connect to RabbitMQ](#3rabbitmq).

## Step 1: Install RabbitMQ

1. Install the required packages:

````
sudo apt-get install curl gnupg apt-transport-https -y

2. ````
Import all necessary keys:

````
curl -1sLf "https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/com.rabbitmq.team.gpg > /dev/null  
curl -1sLf https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key | sudo gpg --dearmor | sudo tee /usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg > /dev/null  
curl -1sLf https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key | sudo gpg --dearmor | sudo tee /usr/share/keyrings/rabbitmq.9F4587F226208342.gpg > /dev/null

````
The latest keys for different versions of RabbitMQ are listed in the [official RabbitMQ documentation](https://www.rabbitmq.com/docs/install-debian#cloudsmith-signing-keys).

3. Add RabbitMQ repositories:

````
sudo tee /etc/apt/sources.list.d/rabbitmq.list <<EOF  
deb \[signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg\] https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu \$(lsb\_release -cs) main  
deb-src \[signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg\] https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu \$(lsb\_release -cs) main  
  
deb \[signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg\] https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu \$(lsb\_release -cs) main  
deb-src \[signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg\] https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu \$(lsb\_release -cs) main  
EOF

4. ````
Update package cache:

````
sudo apt-get update -y

5. ````
Install **Erlang** packages:

````
sudo apt-get install -y erlang-base erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key erlang-runtime-tools erlang-snmp erlang-ssl erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl

6. ````
Install **rabbitmq-server** and its dependencies:

````
sudo apt-get install rabbitmq-server -y --fix-missing

7. ````
Run **rabbitmq-server**:

````
sudo systemctl enable --now rabbitmq-server

## ````
Step 2: Configure RabbitMQ

````
Начало примечание

````
**Note**

The password can contain the following characters:

- Uppercase Latin letters: A to Z

- Lowercase Latin letters: a to z

- Digits: 0 to 9

- Symbols: -\_

Reserved (invalid) characters: \! \* ' ( ) ; : @ \& = + \$ , / ? % # \[ \]

````
Конец примечание

````
To configure RabbitMQ, perform the following actions:

1. Enable necessary plugins:

````
sudo rabbitmq-plugins enable \\  
rabbitmq\_management

2. ````
Make sure to add a **vhost** and grant the user access to it:

````
sudo rabbitmqctl add\_vhost brix365vhost  
sudo rabbitmqctl add\_user brix365user SecretPassword  
sudo rabbitmqctl set\_permissions -p brix365vhost brix365user ".\*" ".\*" ".\*"  
sudo rabbitmqctl set\_user\_tags brix365user administrator

````
Configuring TLS/SSL in RabbitMQ

To enable TLS/SSL support in RabbitMQ, in the **/etc/rabbitmq/rabbitmq.conf** file:

1. Add SSL configuration to **rabbit** (port 5671) and **management** (port 15671) block.

2. Specify the path to the server certificate file in **ssl\_options.certfile** and **management.ssl.certfile** parameters.

3. Specify the path to the private key file in **ssl\_options.keyfile** and **management.ssl.keyfile** parameters.

4. Specify the path to the root CA file in **ssl\_options.cacertfile** and **management.ssl.cacertfile** parameters.

````
listeners.tcp = none  
listeners.ssl.default = 5671  
ssl\_options.cacertfile = /path/to/ca\_certificate.pem  
ssl\_options.certfile = /path/to/server\_certificate.pem  
ssl\_options.keyfile = /path/to/server\_key.pem  
ssl\_options.verify = verify\_peer  
ssl\_options.fail\_if\_no\_peer\_cert = true  
  
management.ssl.port = 15671  
management.ssl.cacertfile = /path/to/ca\_certificate.pem  
management.ssl.certfile = /path/to/server\_certificate.pem  
management.ssl.keyfile = /path/to/server\_key.pem

5. ````
Restart the RabbitMQ service:

````
sudo systemctl restart rabbitmq-server

````
For more details on TLS/SSL configuration in RabbitMQ, refer to [RabbitMQ TLS Support](https://www.rabbitmq.com/ssl.html).

## Step 3: Connect to RabbitMQ

Connection string to RabbitMQ:

````
amqp://brix365user:SecretPassword@<rabbitmq-server-address>:5672/brix365vhost

````
Connection string to RabbitMQ with TLS/SSL:

````
amqps://brix365user:SecretPassword@<rabbitmq-server-address>:5671/brix365vhost
````