anupdhml / sarama

Sample project of using sarama

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sarama

This is a sample project to use sarama, sarama is golang client library for Apache kafka. This repositry contains simple producer and consumer. To use this you need to prepare kafka (or you can run it by docker image).

Install

To get sarama,

$ go get github.com/Shopify/sarama

Build

To build producer & consumer, run below. Binary is generated in each directory,

$ make build

Usage

Ensure kafka is running on where you expect.

To execute consumer, run below. Consumer tries to fetch topic until received os.Interrupt signal.

$ ./consumer/consumer

To execute async-producer, run below. Producer tries to publish messages until received os.Interrupt signal.

$ ./async-producer/async-producer

Kafka on Docker

You can run kafka on docker. And you can also run producer & consumer on docker.

To build docker image of kafka,

$ make docker-build

To run kafka container,

$ ./docker-run.sh

To execute consumer,

$ docker exec -it kafka /work/consumer/consumer

To execute async-producer,

$ docker exec -it kafka /work/async-producer/async-producer

To execute http-log-producer,

$ docker exec -it kafka /work/http-log-producer/http-log-producer

And access it (e.g., docker is on boot2docker),

$ curl $(boot2docker ip):8080

Author

Taichi Nakashima

About

Sample project of using sarama

License:MIT License


Languages

Language:Go 90.1%Language:Shell 5.3%Language:Makefile 4.5%