Building Microservices with Redis and Golang. Enable Gorm and struct migration.

Lefteris Vourgas
4 min readOct 8, 2024

Message Queuing and Database Storage

Introduction

Microservices allow you to build highly decoupled, scalable systems. In this article, we will create two microservices using Golang: one that publishes messages to Redis, and another that listens for those messages and stores them in a PostgreSQL database. This setup decouples the message-publishing process from the database storage operations, improving scalability and reliability.

By the end of this article, you’ll learn how to:

  • Build a message-publishing microservice in Golang that uses Redis as a message broker.
  • Build a separate microservice that listens to Redis and stores messages in a PostgreSQL database.
  • Modularize Redis initialization for both microservices.

Let’s dive into it!

Project Overview

We are going to build two simple microservices:

  1. Message Publisher (Microservice 1): This service receives an event (such as a new order), formats it as a message, and publishes it to a Redis channel.
  2. Message Subscriber (Microservice 2): This service listens to the…

--

--

Lefteris Vourgas

Senior Cloud Engineer and GoLang enthusiast, Specializing in building Kubernetes Operators and Cloud infrastructure. AWS | GO | K8s