Golang Microservices: Events and Background Jobs using RabbitMQ



Golang Microservices: Events and Background Jobs using RabbitMQ

Golang Microservices: Events and Background Jobs using RabbitMQ

Let’s add support for RabbitMQ! RabbitMQ is a message-queueing software also known as a message broker or queue manager. It supports protocols such as AMQP, MQTT, STOMP, to name a few.

RabbitMQ could be used for long-running tasks, for example background jobs; and for communication between different services.

In this RabbitMQ tutorial, for our example we will use RabbitMQ to produce events that indicate Tasks procesed, either “created”, “updated” or “archived”; then a new ElasticSearch Indexer server is implemented to consume those events and call the corresponding ElasticSearch repository type to update the ElasticSearch values.

This new server supports a similar API just like net/http, making it simple to handle a graceful shutdown to clean up all the used resources.

In Go to interact with RabbitMQ, we can use:

* github.com/streadway/amqp

This episode is not going to compare RabbitMQ with other Message Brokers, like Kafka or SQS, but I’m planning to do that in the future.

* Example code: https://github.com/MarioCarrion/todo-api-microservice-example/tree/b886f4346851c860728ec7924d8b3196139af11e
* Previous Episode: “Golang Microservices: Searching with ElasticSearch”: https://youtu.be/ZrdbQRYst5E
* Playlist “Building Microservices in Go/Golang”: https://www.youtube.com/playlist?list=PL7yAAGMOat_Fn8sAXIk0WyBfK_sT1pohu
* Playlist “Golang Tools and Packages”: https://www.youtube.com/playlist?list=PL7yAAGMOat_HEEOvH99agDs_5g51A0Ls3
* Playlist “Testing in Go”: https://www.youtube.com/playlist?list=PL7yAAGMOat_HSeW4zF0uRL9EaHadE4ZZq

00:00 – Start
00:19 – What is RabbitMQ?
00:53 – How does RabbitMQ work?
02:00 – Demo time
13:04 – Parting words

Who am I:

Hello👋🏼! I’m Mario, a Hands-on Software Architect and Lead Backend Engineer with more than 16 years of professional experience building all kinds of software including on-premise Industrial Automation Systems, Linux Accessibility Desktop and Browser Components as well as Distributed Advertising Microservices.

Every week I will share with you different topics I’ve learned while working for small startups and large companies including the processes I’ve followed over the years for successfully delivering complex enterprise systems from start to end.

Subscribe if you like Software Development, Software Architecture and Systems Design!

Keep it up. Don’t give up!

#golang #microservices #programming

— Our affiliate links below

Shop our favorite products → https://www.amazon.com/shop/rubycarrion
Vlogging setup → https://rubycarrion.com/camerasforvlogging/
Get a 30 day FREE trial of Epidemic Sound → https://www.epidemicsound.com/referral/szx441/
Try Amazon Prime 30-Day FREE trial → https://amzn.to/3s0el1R
I love getting Cash Back and think you will too! Join for free and get $20 when you spend $20 → https://www.rakuten.com/r/RUBYRA132?eeid=28187
Sign up to start using vidIQ to grow your YouTube channel for FREE → https://vidiq.com/rubycarrion

— Our Vlog Channel

https://www.youtube.com/c/RubyCarrion/videos

Comments are closed.