Golang的Kafka 框架支持consumer group

golang的kafka 框架有不少种, sarama是一种比较经常使用的,是用golang写的,可是不能支持consumer group。
confluent是一种,是调用c语言的库librdkafka,能够支持consumer group。可是会麻烦一点,须要安装librdkafka。html

安装librdkafka

先看官网上的一句话。
This client for Go depends on librdkafka v1.1.0 or later
用yum install安装的版本是不适合要求的。golang

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.htmlweb

Navigate to /etc/yum.repos.d/ and create a file named confluent.repo with these contents. This adds the Confluent repository.centos

[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
baseurl=https://packages.confluent.io/rpm/5.3
gpgcheck=1
gpgkey=https://packages.confluent.io/rpm/5.3/archive.key
enabled=1

而后
yum install pkg-config
yum install librdkafka-devel框架

在golang中导入
gopkg.in/confluentinc/confluent-kafka-go.v1/kafkasvg