This is example repository how to use kafka in golang, with sarama, goavro, and gogen avro
- plain : example publish and consume using string
- avro : example publish and consume using Avro data. to generate avro schame -> struct, please go folder
avro/schema
and run following command
gogen-avro . test.avsc
will send/publish 10 message
- producer : please go folder
cmd/plain/producer
and run commandgo run main.go
- consumer : please go folder
cmd/plain/consumer
and run commandgo run main.go
will send/publish avro data (name, age)
- producer : please go folder
cmd/avro/producer
and run commandgo run main.go
- consumer : please go folder
cmd/avro/consumer
and run commandgo run main.go
- brew install kafka (will install java 1.8, zookeeper, and kafka)
- zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties
- kafka-server-start /usr/local/etc/kafka/server.properties
- brew services start zookeeper
- brew services start kafka
That's it. If you want to stop Kafka, just run the brew services commands in reverse:
- brew services stop kafka
- brew services stop zookeeper