golang的kafka 框架有很多种, sarama是一种比较常用的,是用golang写的,但是不能支持consumer group。
confluent是一种,是调用c语言的库librdkafka,可以支持consumer group。但是会麻烦一点,需要安装librdkafka。
安装librdkafka
先看官网上的一句话。
This client for Go depends on librdkafka v1.1.0 or later
用yum install安装的版本是不适合要求的。
For Redhat based distros, install librdkafka-devel using Confluent’s YUM repository.
对于CentOS需要先安装Confluent的yum源。
具体方法:
https://docs.confluent.io/current/installation/installing_cp/rhel-centos.html
Navigate to /etc/yum.repos.d/ and create a file named confluent.repo with these contents. This adds the Confluent repository.
[Confluent.dist]
name=Confluent repository (dist)
baseurl=https://packages.confluent.io/rpm/5.3/7
gpgcheck=1
gpgkey=https://packages.confluent.io/rpm/5.3/archive.key
enabled=1
[Confluent]
name=Confluent repository
b

本文介绍了如何在Golang中使用Confluent Kafka库支持Consumer Group。由于sarama框架不支持Consumer Group,作者转向了调用C库librdkafka的confluent-kafka-go。在CentOS上,需要通过Confluent的YUM仓库安装librdkafka-devel,并导入特定的Golang包来使用。
最低0.47元/天 解锁文章
2965

被折叠的 条评论
为什么被折叠?



