Episode 109 - RabbitMQ

The Backend Engineering Show with Hussein Nasser

Episode | Podcast

Date: Sun, 03 Nov 2019 20:28:07 GMT

<p>RabbitMQ</p> <p>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.</p> <p>(slide)</p> <p>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.</p> <ul> <li>RabbitMQ Components(slide)</li> <li>*Publisher</li> <li>*Consumer</li> <li>*Connection</li> <li>*Channel</li> <li>*Queue</li> <li>Spin RabbitMQ server with Docker</li> <li>Write a Publisher client NodeJs</li> <li>Write a Consumer client Nodejs</li> <li>My Thoughts about this tech</li> <li>Summary</li> </ul> <p>timecodes</p> <p>components 2:00</p> <p>spin up docker rabbit 8:30</p> <p>Write a Publisher client NodeJs 11:00</p> <p>Write a consumer client NodeJs 20:30</p> <p>my thoughts 33:50</p> <p>Source Code: <a href="https://github.com/hnasr/javascript_playground/tree/master/rabbitmq">https://github.com/hnasr/javascript_playground/tree/master/rabbitmq</a></p> <p>Example</p> <p>Schedule async job</p> <p>Exchange</p> <p>Queues</p> <p>Publisher</p> <p>Consumer</p> <p>AMQP</p> <p>Channel</p> <p>Connection</p> <p>HTTP</p> <p>AMQP</p> <p>Uses Channels and Queues</p> <p>Multiples channels into one connections</p> <p>docker run --name rabbitmq -p 5672:5672 -d rabbitmq</p> <p>docker run --name rabbitmq -p 5672:5672 -p 15672:15672 -d rabbitmq:3-management</p> <p>HTTP</p> <p>fetch("<a href="http://localhost:15672/api/vhosts">http://localhost:15672/api/vhosts</a>”, {headers: {"Authorization" : `Basic ${btoa('guest:guest')}`}}).then(a=&gt;a.json()).then(console.log)</p> <p>fetch("http://localhost:15672/api/channels", {headers: {"Authorization" : `Basic ${btoa('guest:guest')}`}}).then(a=&gt;a.json()).then(console.log)</p> <p>fetch("http://localhost:15672/api/queues", {headers: {"Authorization" : `Basic ${btoa('guest:guest')}`}}).then(a=&gt;a.json()).then(console.log)</p> <p><a href="https://www.squaremobius.net/amqp.node/channel_api.html#channel_bindExchange">https://www.squaremobius.net/amqp.node/channel_api.html#channel_bindExchange</a></p> <p><a href="https://www.rabbitmq.com/tutorials/tutorial-three-javascript.html">https://www.rabbitmq.com/tutorials/tutorial-three-javascript.html</a></p>