Skip to content

Simple example of microservices architecture with golang using kafka as broker

Notifications You must be signed in to change notification settings

EstebanDem/go-kafka-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microservices with Kafka as Broker - Example

Architecture diagram

Microservices with kafka - golang

  • registration-service: handles the client request and register users in the DB, it produces to new-user topic.it listens to events that modify user's status by http
  • broker-service: listens to messages in every topic and redirects them to interested apps
  • email-service: validate email request from broker and, if valid, produces to email-validator topic

Run Locally

Initiate Kafka with Zookeeper

I used kafka 2.11-0.11.0.1 but it should work any other higher versions, you can download it from https://kafka.apache.org/downloads

Run Zookeeper

  bin/zookeeper-server-start.sh config/zookeeper.properties

Run Kafka

  bin/kafka-server-start.sh config/server.properties

Create topics

  # New user topic
  bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic new-user
  # Email Validation topic
  bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic email-validation

Clone the project

  git clone https://github.com/EstebanDem/go-kafka-example

Go to the project directory

  cd go-kafka-example

Run every microservice

  cd broker-service
  go run cmd/main.go
  cd registration-service
  go run cmd/main.go
  cd email-service
  go run cmd/main.go

Demo

demo.mp4

About

Simple example of microservices architecture with golang using kafka as broker

Topics

Resources

Stars

Watchers

Forks

Languages