Kafka Go client quick start

Abhishek Gupta
1 min readSep 14, 2018

--

Here is a Docker based example for Kafka using Go client

Photo by Braden Collum on Unsplash

These are simple producer and consumer apps based on Confluent Go client for Kafka which itself is built on top of librdkafka (Kafka C client)

I struggled with the Windows setup and chose the Docker route — client setup part is taken care of with a pre-built Docker image — here is the Dockerfile. You can also opt to build your image and update the producer and consumer Dockerfile(s) to reference them

Producer

  • uses the traditional API for pushing messages to Kafka (channel is another option)
  • receives notifications on the (default) Events (custom channel is another option or you can choose not to get notified)

Consumer — uses (Events) channel – Poll()ing is another alternative

To run

Check out the README — it’s super easy to get going, thanks to Docker Compose which is used to bootstrap the sample app (producer and consumer) as a single unit

BYOK (bring your own Kafka) for trying this out. For Kafka on Docker — I would recommend using Confluent Docker images or wurstmeister/kafka is also a great option

References

Cheers!

Originally published at simplydistributed.wordpress.com on September 14, 2018.

--

--

Abhishek Gupta

Principal Developer Advocate at AWS | I ❤️ Databases, Go, Kubernetes