045 Install and configure RabbitMq - chempkovsky/CS82ANGULAR GitHub Wiki

Notes

  • As it was mentioned in the article 038, we are going to use RabbitMq as a transport for our MassTransit Service bus.
  • Thus, RabbitMq must be installed and configured in our local or virtual network environment.
    • We will install RabbitMq in the Windows virtual machine.

Steps required to accomplish the task

Download RabbitMq

Windows specific Issues

  • Read the article.
  • If you do using Chinese, ... ,Russian(our case) operation system we highly recommend to set RABBITMQ_BASE before you start installation process.
    • we had some problems with pure default setting for RabbitMq

Set RABBITMQ var

We need to set RABBITMQ_BASE-variable first

  • open the System-page
Click to show the picture

project structure

  • Click About and click Advanced system settings. System property-dialog will be shown.
Click to show the picture

project structure

  • On the System property-dialog click Environment variables-button. Environment variables-dialog will be shown
Click to show the picture

project structure

  • On the Environment variables-dialog click New-button and set the path you like for the RABBITMQ_BASE-var.
    • use ASCII Characters to define the path
Click to show the picture

project structure

  • we set RABBITMQ_BASE=C:\RabbitMq. You can define another path.

Install RabbitMq

  • follow the instruction

Available commands

  • After installation finished click windows Start-button
    • Click Install service
    • Click Start service
Click to show the picture

project structure

Guest user

  • Default Guest-user (with the passwword=guest) with admin privilege is the only available user. We can not use Guest-user to connect remotely to RabbitMq.
    • So we need to create another user

Virtual host

  • Default RabbitMq Virtual host has a /-name.
  • We will create additional Virtual host for our app.

Management plugin

  • Turning On Management plugin makes Web UI interface enabled. In many cases it simplifies RabbitMq Admin's life.

Setup RabbitMq

enable Management plugin

Click to show the response
C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.16\sbin>rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@SVR2016SQL2017:
rabbitmq_management
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@SVR2016SQL2017...
Plugin configuration unchanged.

C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.16\sbin>
Click to show the picture

project structure

admin user

rabbitmqctl add_user "admin" "admin"
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p "/" "admin" ".*" ".*" ".*"
rabbitmqctl set_topic_permissions -p "/" "admin" ".*" ".*" ".*"
rabbitmqctl list_users
Click to show the response
C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.16\sbin>rabbitmqctl add_user "admin" "admin"
Adding user "admin" ...
Done. Don't forget to grant the user permissions to some virtual hosts! See 'rabbitmqctl help set_permissions' to learn more.

C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.16\sbin>rabbitmqctl set_user_tags admin administrator
Setting tags for user "admin" to [administrator] ...

C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.16\sbin>rabbitmqctl set_permissions -p "/" "admin" ".*" ".*" ".*"
Setting permissions for user "admin" in vhost "/" ...

C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.16\sbin>rabbitmqctl set_topic_permissions -p "/" "admin" ".*" ".*" ".*"
Setting topic permissions on ".*" for user "admin" in vhost "/" ...

C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.16\sbin>rabbitmqctl list_users
Listing users ...
user    tags
admin   [administrator]
guest   [administrator]

C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.16\sbin>

Vhost

rabbitmqctl add_vhost phbkhost
rabbitmqctl set_vhost_limits -p phbkhost "{'max-queues': 30, 'max-connections': 25}"
rabbitmqctl set_permissions -p "phbkhost" "admin" ".*" ".*" ".*"
rabbitmqctl set_topic_permissions -p "phbkhost" "admin" ".*" ".*" ".*"
rabbitmqctl list_exchanges -p "phbkhost"
Click to show the response
C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.16\sbin>rabbitmqctl add_vhost phbkhost
Adding vhost "phbkhost" ...

C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.16\sbin>rabbitmqctl set_vhost_limits -p phbkhost "{'max-queues': 30, 'max-connections': 25}"
Setting vhost limits to "{'max-queues': 30, 'max-connections': 25}" for vhost "phbkhost" ...

C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.16\sbin>rabbitmqctl set_permissions -p "phbkhost" "admin" ".*" ".*" ".*"
Setting permissions for user "admin" in vhost "phbkhost" ...

C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.16\sbin>rabbitmqctl set_topic_permissions -p "phbkhost" "admin" ".*" ".*" ".*"
Setting topic permissions on ".*" for user "admin" in vhost "phbkhost" ...

C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.16\sbin>rabbitmqctl list_exchanges -p "phbkhost"
Listing exchanges for vhost phbkhost ...
name    type
amq.topic       topic
        direct
amq.rabbitmq.trace      topic
amq.direct      direct
amq.fanout      fanout
amq.headers     headers
amq.match       headers

C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.16\sbin>

Install python as desired

exchange queue and binding
  • here is a list of sample commands
python ./rabbitmqadmin declare exchange --vhost="phbkhost" --user="admin" --password="admin" name="phbkexchange" type=direct durable=true
python ./rabbitmqadmin  delete exchange  --vhost="phbkhost" name="phbkexchange" --user="admin" --password="admin"

python rabbitmqadmin declare queue --vhost="phbkhost" --user="admin" --password="admin" name="phbkqueue" durable=true
python rabbitmqadmin delete queue --vhost="phbkhost" --user="admin" --password="admin" name="phbkqueue"

python rabbitmqadmin declare binding --vhost="phbkhost" --user="admin" --password="admin" source="phbkexchange" destination="phbkqueue" routing_key="phbkqueue"
python rabbitmqadmin delete binding --vhost="phbkhost" --user="admin" --password="admin" source="phbkexchange" destination_type="queue" destination="phbkqueue"

python rabbitmqadmin -V "phbkhost" list exchanges
python rabbitmqadmin list queues vhost name node messages
python rabbitmqadmin -f long -d 3 list queues
⚠️ **GitHub.com Fallback** ⚠️