Member-only story
Building Microservices with Redis and Golang. Enable Gorm and struct migration.
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:
- 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.
- Message Subscriber (Microservice 2): This service listens to the…