Listen

Description

RabbitMQ

RabbitMQ is an open source distributed message queue written in Erlang and supports many communication protocols. It was trying to solve the spaghetti 🍝 mesh architecture where every client is communicating with other client in System by introducing an extra layer in the middle.

(slide)

In this video we will explain basic components of RabbitMQ Such as AMQP, channel, queue, publisher, consumer and some stuff, we will also learn how to spin up a RabbitMQ server and we will finally write some code to develop a publisher client that post messages to RabbitMQ. We will also write the consumer piece which will be the code that reads rabbitMQ. Finally I will talk about my personal thoughts on this tech.

timecodes

components 2:00

spin up docker rabbit 8:30

Write a Publisher client NodeJs 11:00

Write a consumer client NodeJs 20:30

my thoughts 33:50

Source Code: https://github.com/hnasr/javascript_playground/tree/master/rabbitmq

Example

Schedule async job

Exchange

Queues

Publisher

Consumer

AMQP

Channel

Connection

HTTP

AMQP

Uses Channels and Queues

Multiples channels into one connections

docker run --name rabbitmq -p 5672:5672 -d rabbitmq

docker run --name rabbitmq -p 5672:5672 -p 15672:15672 -d rabbitmq:3-management

HTTP

fetch("http://localhost:15672/api/vhosts”, {headers: {"Authorization" : `Basic ${btoa('guest:guest')}`}}).then(a=>a.json()).then(console.log)

fetch("http://localhost:15672/api/channels", {headers: {"Authorization" : `Basic ${btoa('guest:guest')}`}}).then(a=>a.json()).then(console.log)

fetch("http://localhost:15672/api/queues", {headers: {"Authorization" : `Basic ${btoa('guest:guest')}`}}).then(a=>a.json()).then(console.log)

https://www.squaremobius.net/amqp.node/channel_api.html#channel_bindExchange

https://www.rabbitmq.com/tutorials/tutorial-three-javascript.html