Skip to content

Instantly share code, notes, and snippets.

@0sc
Created August 22, 2016 22:38
Show Gist options
  • Save 0sc/cd47d90afecaba737c2e9db0d3bab228 to your computer and use it in GitHub Desktop.
Save 0sc/cd47d90afecaba737c2e9db0d3bab228 to your computer and use it in GitHub Desktop.
topic := "kafka-topic-for-the-message" //e.g create-user-topic
partition := -1 //Partition to produce to
msg := "actual information to save on kafka" //e.g {"name":"John Doe", "email":"john.doe@email.com"}
message := &sarama.ProducerMessage{
Topic: topic,
Partition: partition,
Value: sarama.StringEncoder(msg),
}
partition, offset, err := producer.SendMessage(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment