con
github.com/moemoe89/simple-avro-kafka-golang/consumer
go get github.com/moemoe89/simple-avro-kafka-golang/consumer
con

github.com/moemoe89/simple-avro-kafka-golang/consumer

📨 Simple Avro Kafka using Golang for Producer and Consumer with Docker

by Bismo Baruno

v0.0.0-20200306074333-d2cf7220a413 (see all)License:MIT
go get github.com/moemoe89/simple-avro-kafka-golang/consumer
Readme

Simple-Avro-Kafka-Golang

demo

This repository created to show the example for using Avro for serialization & Kafka for publish-subscribe messaging with (Golang) as Simple Producer and Consumer

Running Kafka

Download the latest Kafka version from this link Kafka Download Page and choose the binary downloads.

  • Extract the binaries into some folder. For the example in project/kafka.
  • Go to your kafka extract directory.
  • Start the Zookeeper server with this command bin/zookeeper-server-start.sh config/zookeeper.properties
  • Start the Kafka server with this command bin/kafka-server-start.sh config/server.properties
  • Create the topic : bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic simple-avro-kafka-golang
  • If you want to show the topic list, you can using this command bin/kafka-topics.sh --list --zookeeper localhost:2181
  • Start simple producer for publish message to the topic bin/kafka-console-producer.sh --broker-list localhost:9092 --topic simple-avro-kafka-golang
  • For start simple consumer that can consume message from the topic, you can use this command bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic simple-avro-kafka-golang --from-beginning

Running Kafka with Docker

Build

$ docker-compose build

Run

$ docker-compose up

Stop

$ docker-compose down

Running Simple Kafka Producer using Golang

  • Make sure Running Kafka step already done.
  • Go to your kafka producer directory.
  • Copy config-sample.json to config.json and change the value based on your config.
  • Change Kafka address :
    localhost:9092
    
  • start using go run main.go

Running Simple Kafka Consumer using Golang

  • Make sure Running Kafka step already done.
  • Go to your kafka consumer directory.
  • Copy config-sample.json to config.json and change the value based on your config.
  • Change Kafka address :
    localhost:9092
    
  • start using go run main.go

Send Testing Message using POSTMAN

Make sure you already have POSTMAN

  • Open your POSTMAN.
  • Fill the url with localhost:8789 and choose POST method
  • Select Body tab and choose raw JSON (application/json) and then try to send message with JSON data
{
    "role": "user",
    "data": {
        "id": 4,
        "name": "Dekisugi"
    }
}

GitHub Stars

12

LAST COMMIT

2yrs ago

MAINTAINERS

0

CONTRIBUTORS

1

OPEN ISSUES

1

OPEN PRs

0
VersionTagPublished
v0.0.0-20200306074333-d2cf7220a413
2yrs ago
No alternatives found
No tutorials found
Add a tutorial