Fireship · @fireship

RabbitMQ in 100 Seconds

Uploaded September 6, 2022 · Length 2:31

RabbitMQ in 100 Seconds

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.

  1. 0:00

    rabbit mq an open source distributed

  2. 0:02

    message broker that works like a post

  3. 0:04

    office in the cloud it was developed in

  4. 0:06

    2007 and written in the erlang

  5. 0:09

    programming language which itself is

  6. 0:10

    famous for powering the open telecom

  7. 0:12

    platform in the beginning apps were

  8. 0:14

    built as monoliths with all concerns

  9. 0:16

    coupled together on a single runtime the

  10. 0:18

    problem is that not everything scales in

  11. 0:20

    parallel differing computational needs

  12. 0:22

    gave rise to the microservice

  13. 0:24

    architecture where every concern has its

  14. 0:26

    own run time that scales independently

  15. 0:28

    rabbitmq is a tool that allows these

  16. 0:30

    microservices to communicate

  17. 0:31

    asynchronously with a variety of

  18. 0:33

    different protocols for example you may

  19. 0:35

    have an app that applies deep learning

  20. 0:37

    photo filters when the user clicks a

  21. 0:38

    button that request goes to a rest api

  22. 0:41

    but instead of processing the image

  23. 0:42

    there it produces a message with the

  24. 0:44

    required data and publishes it to an

  25. 0:46

    exchange the exchange is then

  26. 0:48

    responsible for routing it to one or

  27. 0:50

    more queues which are linked to the

  28. 0:51

    exchange with a binding and routing key

  29. 0:54

    now the message sits in the queue until

  30. 0:56

    it's handled by the consumer which in

  31. 0:57

    this case would be the image processing

  32. 0:59

    server the exchange can route directly

  33. 1:01

    to a specific queue or to multiple cues

  34. 1:03

    with a shared pattern using topics or to

  35. 1:06

    every queue it knows about with fanout

  36. 1:07

    the end result is an architecture that

  37. 1:09

    allows servers to both publish and

  38. 1:11

    subscribe to data thanks to the rabbitmq

  39. 1:13

    middleman to get started install it or

  40. 1:15

    run it in a docker container on port

  41. 1:17

    5672 it also contains a cli tool to

  42. 1:21

    manage and inspect your broker now

  43. 1:23

    create a file in your favorite server

  44. 1:24

    side language and bring in a library

  45. 1:26

    that implements a messaging protocol

  46. 1:28

    like advanced messaging queue protocol

  47. 1:30

    091 this file will send a message and

  48. 1:33

    first needs to connect to rabbitmq on

  49. 1:35

    that connection we can use the create

  50. 1:37

    channel method to declare a cue which

  51. 1:39

    can be named whatever you want cues can

  52. 1:40

    be durable where the metadata is stored

  53. 1:42

    on disk or transient where it's only

  54. 1:44

    stored in memory and now produce a

  55. 1:46

    message by sending a buffer to that

  56. 1:48

    queue go ahead and run the file to

  57. 1:49

    create the queue and send the message

  58. 1:51

    then create another file to receive the

  59. 1:52

    message in real life this could be a

  60. 1:54

    different server on the other side of

  61. 1:55

    the world connect to rabbitmq just like

  62. 1:58

    we did for the publisher then reference

  63. 1:59

    the same queue name on that connection