0% found this document useful (0 votes)
45 views24 pages

Rabbitmq

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views24 pages

Rabbitmq

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Message Broker System

Ahmedur Rahman Shovon


Codalo
[email protected]
But I’ll actually talk about RabbitMQ
“Message broker translates a message
from the formal messaging protocol of
the sender to the formal messaging
protocol of the receiver.”
From Wikipedia, the free encyclopedia
RabbitMQ is open source message broker
software that implements the Advanced
Message Queuing Protocol (AMQP).
The principal idea is pretty simple: it
accepts and forwards messages. You can
think about it as a post office: when you
send mail to the post box you're pretty
sure that Mr. Postman will eventually
deliver the mail to your recipient. Using
this metaphor RabbitMQ is a post box, a
post office and a postman!
What can RabbitMQ do for you?
● Messaging enables software applications to connect and scale. Applications can
connect to each other. Messaging is asynchronous, decoupling applications by
separating sending and receiving data.

● Data delivery, non-blocking operations or push notifications, publish / subscribe,


asynchronous processing, or work queues.

● RabbitMQ is a messaging broker - an intermediary for messaging. It gives your


applications a common platform to send and receive messages, and your messages a
safe place to live until received.
Feature Highlights
● Reliability

● Flexible Routing

● Clustering and Federation

● Highly Available Queues

● Multi-protocol with Many Clients

● Plugin System
PRODUCER, QUEUE, CONSUMER
Remember these things please

A producer is a user application that sends messages.


A queue is a buffer that stores messages.
A consumer is a user application that receives messages.
Now let’s see messaging in action!
1 "Hello World!" 4 Routing
The simplest thing that does something Receiving messages selectively

2 Work queues 5 Topics


Distributing tasks among workers Receiving messages based on a pattern

3 Publish/Subscribe 6 RPC
Sending messages to many Remote procedure call implementation
consumers at once
What should I do to play with Rabbits?
Have a Windows machine? Start installing!
● ERLANG 64 bit exe: otp_win64_19.1.exe

● MS Visual C++ redistributable 2013 64 bit

● RabbitMQ Server: rabbitmq-server-3.6.5.exe

● RabbitMQ libraries based on the language

● Python client recommended by the RabbitMQ team: Pika

● Pika Installation: pip install pika


1 “Hello World!” - The simplest thing that does something

Our "Hello world" won't be too complex ‒ let's send a message, receive it and
print it on the screen. To do so we need two programs: one that sends a message
and one that receives and prints it.

Sending message to queue Receiving message from


Sending message...
Producer Script

Message is sent to the


queue
Receiving message...
Consumer Script

Message is received
from the queue
2 Work queues - Distributing tasks among workers

The main idea behind Work Queues (aka: Task Queues) is to avoid doing a
resource-intensive task immediately and having to wait for it to complete.
Instead we schedule the task to be done later.

Sending message to queue Multiple consumers receiving


Producer’s script (new_sender.py)
Producer Script is now
updated to allow run time
argument which contains
messages
Consumer’s / Worker’s script (worker.py)
Receiver Script is now
updated to allow pause to
process the queue
element. Lets think each
consumer as a worker.
We ensure the fair
dispatch of queues using
prefetch_count=1. Each
“#” in message takes 2
seconds to process.
Sending messages...
● Open two cmd and run
worker.py in both
prompt.

● Open another cmd and


run new_sender.py.

● The messages with lot of


# will take much time to
process in worker
Receiving messages...
First worker received and
processed messages faster
because the fifth worker takes
a lot of time to process only
one message which takes
time to process.
Real World Uses
● Fast logging solution

● Sending emails

● Sending SMSs

● Background processing (data analysis)


Want to learn more?
● Go to the official site of RabbitMQ: https://www.rabbitmq.com/

● How about Wiki? : https://en.wikipedia.org/wiki/RabbitMQ


And pass the messages… :D
Thank you.

You might also like