A simple Go project that demonstrates basic work with Apache Kafka: the producer sends messages, and the consumer reads them.
- Language: Go 1.21+
- Message Broker: Apache Kafka
- Zookeeper (for Kafka)
- Containerization: Docker, Docker Compose
- Lib:
github.com/confluentinc/confluent-kafka-go
Download repository using command:
git clone https://github.com/spookysploit/kafka-golang.git
Open the repository:
cd ./kafka-golang
Launch command:
docker compose up --build
After the containers are launched, the web interface will also be available at:
http://localhost:9020/
Download all the dependencies:
go mod tidy
Producer working example (sending messages):
go run ./cmd/producer/main.go
Consumer working example (reading messages):
go run ./cmd/consumer/main.go