Intro to RabbitMQ

1 minute read

Start RabbitMQ on our Local Computer

Pika is the Python library that prvides IO and Event Looping, AMQP is a two-way RPC protocol where the client can send requests to the server and the server can send requests to a client.

rabbitmq Is a Message Broker

brew install pika
brew install rabbitmq

What is RabbitMQ?

  • Message Broker

  • Explain difference concepts and keywords (Exchnages, Queues, Channels)

Lets Start up a RabbitMQ sever on our Computer


In our terminal we will type:

brew services start rabbitmq

To view the rabbitMQ Server, we can go to (http://localhost:15672/)

"insert pic of rabbitmq webserver here"

How do we loginto the Localost that it’s running on?

We can use the default login:

  • username: guest
  • password: guest

To See Services (like RabbitMQ) running on your computer you can use the command:

brew servcies list

output:

Name          Status  User        File
cassandra     none                
dbus          none                
emacs         none                
kafka         none                
minio         none                
mysql         none                
postgresql@14 none                
rabbitmq      started devinpowers ~/Library/LaunchAgents/homebrew.mxcl.rabbitmq.plist
unbound       none                
zookeeper     none 

From above we can see that I have rabbitmq running!

To Stop RabbitMQ Server?

brew services stop rabbitmq

To Reset RabbitMQ Server?

brew services reset rabbitmq

Simple Example

Lets write a program that will send a single message to the queue. Lets establish a connection with a RabbitMQ Server.

import pika

connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()

Were using Pika.

Need to set up a queue so the consumer down the line can get the message

channel.queue_declare(queue='hello')