Fireship · @fireship
RabbitMQ in 100 Seconds
Uploaded September 6, 2022 · Length 2:31
Summary
rabbitmq explained as a distributed message broker for microservices in 100 seconds
- rabbitmq
- microservices
- message broker
- distributed architecture
- mq
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
rabbit mq an open source distributed
- 0:02
message broker that works like a post
- 0:04
office in the cloud it was developed in
- 0:06
2007 and written in the erlang
- 0:09
programming language which itself is
- 0:10
famous for powering the open telecom
- 0:12
platform in the beginning apps were
- 0:14
built as monoliths with all concerns
- 0:16
coupled together on a single runtime the
- 0:18
problem is that not everything scales in
- 0:20
parallel differing computational needs
- 0:22
gave rise to the microservice
- 0:24
architecture where every concern has its
- 0:26
own run time that scales independently
- 0:28
rabbitmq is a tool that allows these
- 0:30
microservices to communicate
- 0:31
asynchronously with a variety of
- 0:33
different protocols for example you may
- 0:35
have an app that applies deep learning
- 0:37
photo filters when the user clicks a
- 0:38
button that request goes to a rest api
- 0:41
but instead of processing the image
- 0:42
there it produces a message with the
- 0:44
required data and publishes it to an
- 0:46
exchange the exchange is then
- 0:48
responsible for routing it to one or
- 0:50
more queues which are linked to the
- 0:51
exchange with a binding and routing key
- 0:54
now the message sits in the queue until
- 0:56
it's handled by the consumer which in
- 0:57
this case would be the image processing
- 0:59
server the exchange can route directly
- 1:01
to a specific queue or to multiple cues
- 1:03
with a shared pattern using topics or to
- 1:06
every queue it knows about with fanout
- 1:07
the end result is an architecture that
- 1:09
allows servers to both publish and
- 1:11
subscribe to data thanks to the rabbitmq
- 1:13
middleman to get started install it or
- 1:15
run it in a docker container on port
- 1:17
5672 it also contains a cli tool to
- 1:21
manage and inspect your broker now
- 1:23
create a file in your favorite server
- 1:24
side language and bring in a library
- 1:26
that implements a messaging protocol
- 1:28
like advanced messaging queue protocol
- 1:30
091 this file will send a message and
- 1:33
first needs to connect to rabbitmq on
- 1:35
that connection we can use the create
- 1:37
channel method to declare a cue which
- 1:39
can be named whatever you want cues can
- 1:40
be durable where the metadata is stored
- 1:42
on disk or transient where it's only
- 1:44
stored in memory and now produce a
- 1:46
message by sending a buffer to that
- 1:48
queue go ahead and run the file to
- 1:49
create the queue and send the message
- 1:51
then create another file to receive the
- 1:52
message in real life this could be a
- 1:54
different server on the other side of
- 1:55
the world connect to rabbitmq just like
- 1:58
we did for the publisher then reference
- 1:59
the same queue name on that connection


