kafka

command module
v0.0.0-...-838b099 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2023 License: MIT Imports: 12 Imported by: 0

README

Kafka Pubsub using Watermill Library

An example of implementing an event-driven application using pubsub pattern with kafka as the message broker. We leverage the Watermill framework to set up our connection to kafka.

Overview

The code in this example is based on the Kafka example found in the Watermill project with the following differences:

  • Our example uses bitnami Kafka and Zookeeper docker images instead of Confluence docker images.
  • Our go program runs outside of Docker network, hence the broker URL points to localhost.
  • The code for sending and receiving Kafka messages are implemented as goroutines.

Setup

  1. Run Kafka and Zookeeper.

    $ docker-compose up
    
  2. Run the go program.

    $ go run main.go
    
  3. Terminate the programs.

    $ # Press CTRL-C to terminate the go program
    $ # Next shutdown kafka and zookeeper
    $ docker-compose down
    
  4. Alternatively, you can run everything with just 2 commands.

    $ make run
    $ make teardown    # Run this to remove the containers
    

Reference and Credits

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL