An open API service indexing awesome lists of open source software.

https://github.com/tx7do/go-kafka-example


https://github.com/tx7do/go-kafka-example

confluent-kafka goka kafka nats paho-mqtt sarama segmentio streadway-amqp

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

          

# go-kafka-example

## 本地Docker搭建Kafka服务器

```shell
docker pull bitnami/kafka:latest
docker pull bitnami/zookeeper:latest

docker run -d \
--name zookeeper-test \
-p 2181:2181 \
-e ALLOW_ANONYMOUS_LOGIN=yes \
bitnami/zookeeper:latest

docker run -d \
--name kafka-standalone \
--link zookeeper-test \
-p 9092:9092 \
-v /home/data/kafka:/bitnami/kafka \
-e KAFKA_BROKER_ID=1 \
-e KAFKA_LISTENERS=PLAINTEXT://:9092 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092 \
-e KAFKA_ZOOKEEPER_CONNECT=zookeeper-test:2181 \
-e ALLOW_PLAINTEXT_LISTENER=yes \
--user root \
bitnami/kafka:latest
```

## Kafka Golang客户端

| 项目名 | 特点 | 缺点 |
|--------------------------------------------------------------------------|------------------|---------------------|
| [Shopify/sarama](https://shopify.github.io/sarama) | 最受欢迎 | 集群式消费难实现,不支持Context |
| [bsm/sarama-cluster](https://github.com/bsm/sarama-cluster) | 基于sarama补充集群式消费 | 不支持Context |
| [lovoo/goka](https://github.com/lovoo/goka) | 依赖于sarama | 不支持Context |
| [confluent-kafka-go](https://github.com/confluentinc/confluent-kafka-go) | | 依赖C语言库,不支持Context |
| [segmentio/kafka-go](https://github.com/segmentio/kafka-go) | 同时支持集群模式,易与软件交互 | 未正式发布,支持Context |

## Kafka 客户端管理工具

- [Offset Explorer](https://www.kafkatool.com/download.html)
- [EFAK](https://www.kafka-eagle.org/)

## 参考资料

- [Kafka客户端--Go版本](https://jjmeg.github.io/posts/kafka-golang-client/)
- [为什么不推荐使用Sarama Go客户端收发消息?](https://help.aliyun.com/document_detail/266782.html)
- [关于 Kafka 应用开发知识点的整理](https://pandaychen.github.io/2022/01/01/A-KAFKA-USAGE-SUMUP-2/)
- [kafka-go 读取kafka消息丢失数据的问题定位和解决](https://cloud.tencent.com/developer/article/1809467)
- [sarama的消费者组分析、使用](https://www.cnblogs.com/payapa/p/15401357.html)
- [多个Kafka消费者如何同时消费相同Topic下的相同Partition的数据?](https://zhuanlan.zhihu.com/p/392259838)