Discover Packages
github.com/cybersamx/go-recipes/kafka-pubsub
command
module
Version:
v0.0.0-...-5f7a64d
Opens a new window with list of versions in this module.
Published: Jul 6, 2022
License: MIT
Opens a new window with license information.
Imports: 12
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
README
¶
Kafka Pubsub using Watermill Library
An example of implementing an event-driven application using pubsub pattern with Kafka as the message broker and Watermill framework .
Overview
This sample code is basically based on the Kafka example found in the Watermill project . Other than the following differences, the sample code is similar to the Watermill Kafka example:
Uses bitnami Kafka and Zookeeper docker images instead of Confluence docker images.
The go program runs outside of Docker network, hence the broker URL points to localhost.
Run the processors for sending and receiving Kafka messages as goroutines.
Setup
Run Kafka and Zookeeper.
$ docker-compose up
Run the go program.
$ go run main.go
Terminate the programs.
$ # Press CTRL-C to terminate the go program
$ # Next shutdown kafka and zookeeper
$ docker-compose down
Alternatively, you can run everything with just 2 commands.
$ make
$ make teardown # Run this to remove the containers
Reference and Credits
Expand ▾
Collapse ▴
Documentation
¶
There is no documentation for this package.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.