045 Install and configure RabbitMq - chempkovsky/CS82ANGULAR GitHub Wiki
- Download RabbitMq
- Windows specific Issues
- Install RabbitMq
- Available commands
- Guest user
- Virtual host
- Management plugin
- Setup RabbitMq
- 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.
- go to the official site
- follow the instructions of the page
- 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
- we had some problems with
We need to set RABBITMQ_BASE
-variable first
- open the
System
-page
Click to show the picture
- Click
About
and clickAdvanced system settings
.System property
-dialog will be shown.
Click to show the picture
- On the
System property
-dialog clickEnvironment variables
-button.Environment variables
-dialog will be shown
Click to show the picture
- On the
Environment variables
-dialog clickNew
-button and set the path you like for theRABBITMQ_BASE
-var.- use
ASCII Characters
to define the path
- use
Click to show the picture
- we set
RABBITMQ_BASE
=C:\RabbitMq
. You can define another path.
- follow the instruction
- After installation finished click windows
Start
-button- Click Install service
- Click Start service
Click to show the picture
- Default
Guest
-user (with the passwword=guest
) with admin privilege is the only available user. We can not useGuest
-user to connect remotely to RabbitMq.- So we need to create another user
- Default RabbitMq Virtual host has a
/
-name. - We will create additional Virtual host for our app.
- Turning On Management plugin makes Web UI interface enabled. In many cases it simplifies RabbitMq Admin's life.
- run RabbitMq command prompt
- enable Management plugin with
rabbitmq-plugins enable rabbitmq_management
-command
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
- run RabbitMq command prompt
- execute the commands
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>
- run RabbitMq command prompt
- execute the commands
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>
- Optionally, we can install python
- 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