RabbitMQ Intro

SETUP :
Erlang Download : https://www.erlang.org/downloads
RabbitMQ Windows Download : https://www.rabbitmq.com/docs/install-windows
Python Download : https://www.python.org/downloads/

https://www.rabbitmq.com/docs/management-cli
https://www.rabbitmq.com/docs/man/rabbitmq-plugins.8
https://www.rabbitmq.com/management.html
https://www.python.org/downloads/

1. Install Erlang (Erlang 26.2.5)
2. Install Rabbitmq (RabbitMQ 3.13.2)

To Start Use RabbitMQ :
1. Run rabbitmq command prompt for start from windows menu -> click the “Rabbitmq Service – Start”. Wait few seconds , it will run and close itself.
2. Go to sbin directory – “C:\Program Files\RabbitMQ Server\rabbitmq_server-3.13.2\sbin>”
3. rabbitmq-plugins.bat list
4. rabbitmq-plugins.bat enable rabbitmq_management

5. Browse the url
http://localhost:15672/
http://localhost:15672/cli/rabbitmqadmin
user : guest & guest
6. Run rabbitmq command prompt for stop

C:\Users\Administrator\AppData\Roaming\RabbitMQ\log

********
Configure & Test : rabbitmqadmin

1. Install Python
2. Add Python to your PATH. Configure Env path : C:\Users\Administrator\AppData\Local\Programs\Python\Python312
3. From the RabbitMQ management interface. Download rabbitmqadmin from the admin portal “http://localhost:15672/cli/rabbitmqadmin”
4. Move rabbitmqadmin to your sbin directory – “C:\Program Files\RabbitMQ Server\rabbitmq_server-3.13.2\sbin>”
5. Execute the commands with python prefix “python rabbitmqadmin list queues”

—Exchane
python rabbitmqadmin list exchanges
python rabbitmqadmin declare exchange name=elon-musk-exchange type=direct

Types:
Direct – to only one queue
Fanout – to all queues

—Queue
python rabbitmqadmin list queues
python rabbitmqadmin declare queue name=tesla-queue
python rabbitmqadmin declare queue name=spacex-queue

—Binding
python rabbitmqadmin list bindings
python rabbitmqadmin declare binding source=’elon-musk-exchange’ destination=’tesla-queue’
python rabbitmqadmin declare binding source=’elon-musk-exchange’ destination=’spacex-queue’

—Routting Key
python rabbitmqadmin declare binding source=’elon-musk-exchange’ destination=’tesla-queue’ routting_key = “tesla”
python rabbitmqadmin declare binding source=’elon-musk-exchange’ destination=’spacex-queue’ routting_key = “spacex”

Configure & Test – rabbitmqctl

1. To list exchanges in RabbitMQ on a Windows system use cmd tool – rabbitmqctl
2. navigate to dir “cd C:\Program Files\RabbitMQ Server\rabbitmq_server-x.x.x\sbin”
3. To list all exchanges, Run the cmd : rabbitmqctl.bat list_exchanges
rabbitmqctl.bat list_queues
rabbitmqctl.bat list_bindings
rabbitmqadmin declare binding source=”source-exchange” destination_type=”queue” destination=”queue-name” routing_key=”binding-key”

Error :
by running this command , i am getting this error message :
Error: unable to perform an operation on node ‘rabbit@DESKTOP-RBN1038’. Please see diagnostics information and suggestions below.

Solution :
1. Check if RabbitMQ service is running
2. Verify hostname resolution ‘rabbit@DESKTOP-RBN1038’
3. Check the Erlang cookie:
The Erlang cookie is used for authentication between the RabbitMQ server and CLI tools. Ensure that the CLI tool and the RabbitMQ server are using the same Erlang cookie.

Locate the Erlang cookie file, typically found at:
For the RabbitMQ server: C:\Windows\System32\config\systemprofile\.erlang.cookie
For the user running the CLI tool: C:\Users\YourUsername\.erlang.cookie
Ensure the contents of these files are identical. If not, copy the cookie file from the server to your user’s directory.

Erlang Cookie File : C:\Windows\System32\config\systemprofile
C:\Users\Administrator

Ref :
Link 1
Link 2
Link 3

Leave a Reply

Your email address will not be published. Required fields are marked *