RabbitMQ Installation - Message Queue
  • 24 Jun 2024
  • 3 Minutes to read
  • Dark
    Light
  • PDF

RabbitMQ Installation - Message Queue

  • Dark
    Light
  • PDF

Article summary

Overview

The outlined process ensures the successful installation and configuration of RabbitMQ on designated servers. Key outcomes include enhanced security through firewall adjustments, seamless connectivity between RabbitMQ, App servers, and databases, and the creation of an administrator user for simplified management via the RabbitMQ Management Web dashboard.

Installation Steps

Instead of the traditional approach in Reconciliation that uses REST API and a File-based System, a new reconciliation technique, Message Queue System (Rabbit MQ) has been introduced.

Note:

As per the architecture finalized, identify the server where the respective component is to be installed and configured.

Pre-requisites:

  1. Server with a sudo non-root user.

  2. If you have a firewall enabled, configure it to allow traffic on the ports used by RabbitMQ.

  3. Ensure connectivity between RabbitMQ and App servers (Tomcat).

  4. Ensure connectivity between RabbitMQ and the database.

Installation

Steps to install the RabbitMQ server on RHEL:

  1. Install Erlang with the below command:

    sudo yum install erlang

  2. Install RabbitMQ server:

    sudo yum install epel-release

    sudo yum install rabbitmq-server

  3. Confirm the version of RabbitMQ installed:

    $ rpm -qi rabbitmq-server

Now that you have RabbitMQ installed on your Fedora, start and enable the service to start on system boot:

sudo systemctl start rabbitmq-server

sudo systemctl enable rabbitmq-server

You can enable the RabbitMQ Management Web dashboard for easy management:

sudo rabbitmq-plugins enable rabbitmq_management

The Web service should be listening on TCP port 15672, verify this via the below command:

# ss -tunelp | grep 15672

Note:

If you have an active Firewall service, allow ports 5672 and 15672.

Create an Administrator user for RabbitMQ

Setup an administrator user account for accessing the RabbitMQ server management console via the below commands:

sudo rabbitmqctl add_user mqadmin Admin123*

sudo rabbitmqctl set_user_tags mqadmin administrator  

Steps to install the RabbitMQ server on Ubuntu:

  1. Update the package list

    sudo apt update

  2. Install Erlang

    sudo apt install erlang

  3. Add RabbitMQ APT Repository

    sudo apt-key adv --keyserver "keyserver.ubuntu.com" --recv-keys "0x6B73A36E6026DFCA"

    sudo tee /etc/apt/sources.list.d/bintray.rabbitmq.list <<EOF

    deb https://dl.bintray.com/rabbitmq-erlang/debian bionic erlang

    deb https://dl.bintray.com/rabbitmq/debian bionic main

    EOF

  4. Update Package List Again

    sudo apt update

  5. Install RabbitMQ Server

    sudo apt install rabbitmq-server

  6. Start RabbitMQ Service

    sudo systemctl start rabbitmq-server

  7. Enable RabbitMQ Service to Start on Boot  

    sudo systemctl enable rabbitmq-server

  8. Check RabbitMQ Status

    sudo rabbitmqctl status

  9. Create a RabbitMQ Admin User (Optional)

    You can create an admin user for the RabbitMQ Management Plugin. Replace your_username and your_password with your desired values.

    sudo rabbitmqctl add_user your_username your_password

    sudo rabbitmqctl set_user_tags your_username administrator

    sudo rabbitmqctl set_permissions -p / your_username ".*" ".*" ".*"

    Install RabbitMQ Management Plugin (Optional)  

    This step is optional but recommended for managing RabbitMQ through a web interface.

    sudo rabbitmq-plugins enable rabbitmq_management  

Configuration Steps  

Create Queue from RabbitMQ Management Dashboard.

  1. Login with this admin username and the password assigned.

    http://RabbitMQserver-IPAddress:15672

  2. Go to the Queues tab and create a new queue, keep all default values  while creating new queue except two fields below.

    Name: CIRabbitMQ

    Type: Classic

    Durability: Transient

  3. Go to the Admin tab and click on the admin user which was created earlier.

  4. Provide the permission to "can access virtual hosts" as "/".

Setting up the RabbitMQReceiver.jar file:

  1. Get the rabbitMQ receiver .jar file from the CI team.

  2. Open the receiver file using 7-zip (preferably).

  3. BOOT-INF -> classes -> mq -> application.properties

  4. Edit the application.properties as follows:

    Note:

    Make sure to use the correct DB_URL, username and password for CI DB, as well as Audit DB. (Same as used in hcp.properties)

  5. Create a new folder in the CI server. Example, /opt/MQReceiver and copy the .jar file in the directory.

  6. Create a new directory named logs, /opt/MQReceiver/logs

  7. Run the following command while you’re in the MQReceiver directory:

    java -jar CIDAgentRabbitMQReceiver.jar > logs/logs.out 2>&1 &

   Outcome

The document ensures a successful RabbitMQ installation with enhanced security and seamless connectivity on designated servers. Key outcomes include the establishment of firewall rules, the creation of an administrator user, and the configuration of RabbitMQ for optimal performance, enabling efficient message queue-based communication between applications.

Operations and Maintenance

These commands are essential for managing RabbitMQ operations, such as starting, stopping, restarting the service, and checking the status.

  1. To start RabbitMQ services:

    sudo systemctl start rabbitmq-server

  2. To stop RabbitMQ services:

    sudo systemctl stop rabbitmq-server

  3. Check RabbitMQ Status

    sudo rabbitmqctl status

  4. To restart RabbitMQ services:

    sudo systemctl restart rabbitmq-server

  5. Enable RabbitMQ service to start on boot

    sudo systemctl enable rabbitmq-server

  6. Disable RabbitMQ service to start on boot

    sudo systemctl disable rabbitmq-server

  7. View RabbitMQ Logs

    sudo journalctl -u rabbitmq-server  


Was this article helpful?