A example to consume kafka message with golang and confluent.
package main
import (
"log"
"github.com/confluentinc/confluent-kafka-go/kafka"
)
func main() {
c, err := kafka.NewConsumer(&kafka.ConfigMap{
"bootstrap.servers": "localhost:9092",
"group.id": "myGroupId",
})
if err != nil {
panic(err)
}
c.SubscribeTopics([]string{"quick-start-event"}, nil)
for {
msg, err := c.ReadMessage(-1)
if err == nil {
log.Println(string(msg.Value))
} else {
log.Fatal("Can not consume message", err)
break
}
}
c.Close()
}
For more information about confluent kafka go please see here.
https://github.com/confluentinc/confluent-kafka-go