Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Created November 30, 2018 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhirockzz/bacaa7abf692f447740e9617b810fc8f to your computer and use it in GitHub Desktop.
Save abhirockzz/bacaa7abf692f447740e9617b810fc8f to your computer and use it in GitHub Desktop.
func main() {
kafkaBroker := "foo:9092"
p, err := kafka.NewProducer(&kafka.ConfigMap{"bootstrap.servers": kafkaBroker})
if err != nil {
fmt.Println("producer creation failed ", err.Error())
return
}
topic := "bar"
partition := kafka.TopicPartition{Topic: &topic, Partition: kafka.PartitionAny}
msg := &kafka.Message{TopicPartition: partition, Key: []byte("hello"), Value: []byte("world")}
err = p.Produce(msg, nil)
fmt.Println("done...")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment