This project is a simple Kafka-based coffee order system using Go. It consists of a producer that sends coffee orders to Kafka and a consumer that processes these orders.
- Kafka and Zookeeper installed and running locally.
- Go installed on your system.
- Sarama library installed (
go get github.com/IBM/sarama
).
-
Clone this repository:
git clone https://github.com/likhithkp/coffee-brew-system cd coffee-brew-system
-
Install dependencies:
go mod tidy
-
Start Kafka and Zookeeper:
# Start Zookeeper bin/zookeeper-server-start.sh config/zookeeper.properties # Start Kafka bin/kafka-server-start.sh config/server.properties
-
Create a Kafka topic:
bin/kafka-topics.sh --create --topic coffee_orders --bootstrap-server localhost:9092 --partitions 1 --replication-factor 1
-
Start the producer service:
go run producer.go
-
Send a POST request to place a coffee order:
curl -X POST http://localhost:3000/produce -H "Content-Type: application/json" -d '{"customer_name":"John Doe", "coffee_type":"Espresso"}'
-
The producer will send the order to Kafka and log a success message.
-
Start the consumer service:
go run consumer.go
-
The consumer will receive coffee orders and process them by printing messages to the console.
- Ensure Kafka is running on
localhost:9092
. - Verify the topic exists using:
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
- Check logs for any errors in producer or consumer.
MIT License