What is RabbitMQ? - YouTube

Channel: IBM Technology

[0]
What is RabbitMQ, and what makes it one of the most popular message brokers out there?
[6]
My name is Whitney Lee.
[7]
I'm a Cloud Developer here at IBM.
[10]
Before I dig in, please, don't forget to hit that subscribe button.
[15]
So, let's travel back in time to the days of monolithic architecture.
[19]
Back then, application components were tightly coupled.
[23]
That means they were directly connected.
[27]
So, in a simple retail application, if we had a checkout service and it needed to communicate
[34]
with an inventory service, that would be done directly through,
[38]
usually through a TCP connection.
[43]
So, this had some limitations.
[45]
As soon as the checkout sent the message,
[48]
it would need to hear a reply before it could move on to the next task.
[51]
Or worse, if the inventory service went down, it would try over and over again
[56]
until it was able to make that connection.
[59]
Or, if a lot of checkouts happened at once the inventory service wouldn't be able to keep up
[64]
and the whole system would get bogged down.
[66]
So, that's why message queues were created -- or, message brokers --
[71]
and those will sit, a message queue sits in between the two services that need
[75]
to communication with one another.
[78]
So, with a message queue, a checkout can add a message to the queue
[82]
and then immediately move on to the next task.
[86]
And then similarly, the inventory, when it's ready, can consume from the queue,
[91]
process the message and then immediately consume the next message.
[95]
So, this is going to decouple the two applications.
[102]
A message broker is also going to help with scalability.
[106]
So, the inventory...if a lot of checkouts happen at once, the queue begins to fill,
[111]
you can have more than one consuming service -- more than one inventory, in our case --
[118]
to read from the queue to handle the amount of workload that the checkout is producing,
[123]
and that's going to make the system more scalable.
[129]
Another big benefit of message queues is that the queue itself can sit on its own machine.
[137]
So, in that case, it can offload some of the work that's done by the Web application
[143]
and make the whole system more performant.
[149]
So, let's talk about RabbitMQ.
[153]
RabbitMQ is an implementation of the AMQP message model --
[158]
that's Advanced Message Queueing Protocol -- and specifically, Version 091.
[166]
So, with this type of message model, the producer, in our case the checkout,
[171]
the service that produces the messages, instead of producing directly to a message queue,
[180]
it's going to produce to an exchange.
[183]
So, you can think of an exchange as a post office.
[188]
It's going to receive all the messages
[189]
and then distribute them according to how they're addressed.
[193]
An exchange could be connected to many queues; in our case, we're going to do two.
[203]
And then, the queues are connected to the consuming services or our consumers.
[210]
So, we'll have one called inventory
[212]
and then we'll do one called shipping might need to consume from a checkout.
[225]
So, the checkout will send a message to the exchange.
[229]
The exchange is connected to queues through connections called bindings,
[234]
and these bindings can be referenced by the binding key.
[242]
And then our consuming applications --
[244]
or, consumers, consuming services -- those subscribe to the queues.
[252]
So, AMQP, RabbitMQ this is the message broker here, this part of the system.
[264]
One thing that's great about this message model I the flexibility
[270]
with which the messages can move through the system, and that flexibility is largely in part
[275]
to the different types of exchanges available.
[277]
So, the first type of exchange that the system can do is a fanout exchange.
[285]
With a fanout exchange, checkout will produce to the exchange,
[288]
the exchange will duplicate the message and send it to every single queue that it knows about.
[293]
Or, we have a direct exchange.
[298]
With the direct exchange, the checkout will produce the message and then
[301]
that message will get a routing key.
[307]
So, with a direct exchange the routing key is being compared to the binding key;
[312]
and if it's an exact match, then the message will move through the system accordingly.
[318]
Next, we have a topic exchange.
[320]
With a topic exchange, we can do a partial match between the routing key and the binding key.
[326]
So, if we had a routing key on this message called ship.shoes
[330]
and the binding key was called ship.any and the exchange type was a topic exchange,
[340]
that message would get routed through to that, this queue.
[345]
There's also a header exchange.
[350]
With a header exchange, the routing key is ignored completely, and the message is moved
[355]
through the system according to the header.
[356]
And then finally, we have a default exchange.
[361]
This exchange is unique only to RabbitMQ.
[363]
It's not part of the AMQP message model.
[367]
So, the default exchange is also called a nameless exchange.
[372]
And with the default exchange, the routing key,
[375]
let's say the routing key of this message is inv.
[378]
The routing key is getting tied to the name of the queue itself.
[381]
So, if this queue is named inv, then the message would route through to there.
[387]
So, there are a couple of main benefits of RabbitMQ right now with the architecture,
[393]
and one is a tremendous amount of flexibility you have moving messages through your system.
[399]
In fact, they say you can design your system with whatever you want, the sky's the limit,
[403]
and then later configure it RabbitMQ to work with your system as opposed to needing
[407]
to know RabbitMQ's limitations and designing your system accordingly.
[412]
Also, with other message brokers the broker administrator when they set
[416]
up the message model, that's when all the configuration for how message moves
[421]
through the system, that's when it's all defined.
[424]
But with RabbitMQ, the way the message moves
[428]
through the system is largely a part of the message metadata.
[432]
So, in this case, it's the application and the developer that has a lot of control
[438]
with the way messages move through the system rather than the broker administrator.
[443]
Another great benefit to RabbitMQ is that it is cloud friendly.
[448]
It is easy to get started.
[453]
You can deploy an instance of it on Docker or other containerization software.
[460]
It also can run as a cluster, so that means it's fault tolerant,
[463]
highly available and has high throughput.
[468]
RabbitMQ can do cross language communication.
[474]
So, if a message is produced by a checkout and go, it can be consumed by inventory
[479]
in JavaScript and consumed by shipping in Python.
[483]
And really the possibilities are endless.
[485]
It has a very extensive library.
[487]
It has good security.
[492]
It supports FASL, LDAP and TLS for authentication and authorization.
[499]
It does message acknowledgements.
[503]
So, message acknowledgements, when a message is in a queue and it goes to the consumer,
[508]
the message stays in the queue until the consumer lets the broker know
[512]
that it has received the message.
[514]
And only then is the message taken out of the queue,
[517]
and that prevents the system from losing any messages.
[522]
It has great management.
[527]
So, right out of the box you have a really good browser based management UI
[531]
as well as incentive CLI tools.
[535]
Not only that, but the open source community has created plugins
[538]
that really enrich the management and moderning part of RabbitMQ.
[542]
And speaking of that open source community, it has created a lot of plugins
[549]
that can enrich most aspects of RabbitMQ.
[552]
There are many tools created, there are lots of clients,
[556]
it's so evolved that RabbitMQ now supports other message models.
[561]
So, not just AMQP 091 but you can do MQTT, Stomp, AMQP 1.0 for example.
[570]
So, this has been an overview of RabbitMQ.
[573]
The big takeaways for you are the flexibility with the ways the messages move
[577]
through the system; the fact that the message metadata defines how messages move
[583]
through the system as opposed to the broker administrator;
[586]
and then, it's also super cloud friendly.
[590]
Thank you.
[591]
If you have questions, please drop us a line below.
[594]
If you want to see more videos like this in the future, please like and subscribe.
[599]
And don't forget, you can grow your skills and earn a badge with IBM Cloud Labs which are free,
[605]
browser based, interactive Kubernetes labs.