drtwqc3744 2017-09-25 15:57
浏览 431

Kafka 0.11 / Golang Sarama版本支持

I spent some time finding that my Go application connecting to a Kafka 0.11 cluster was using the old 0.8.2 version of the library, which is missing the Timestamp value in the response.

I then found that Kafka 0.11.x API/version wasn't supported (but they are working on it).

I have two solutions for now.

First is to set the required version explicitly in my apps. Second is to "tune" the Sarama code to use version 0.10.x as minimum version, enabling me to use all the 0.10.x API/functionality.

I was still wondering why the version is not taken from the Kafka broker I'm connecting to?

I can't understand how it's supposed to work from the code... I clearly see the version that is set or defined in the sarama.Config.Version, but I can't find anything to update this value once connected to a broker?

I know that Python is doing it this way:

from kafka import BrokerConnection
broker=BrokerConnection("localhost",9092,0)
broker.connect()
broker.check_version()

(0, 11, 0)

What am I missing?

  • 写回答

1条回答 默认 最新

  • douqilin4296 2017-09-25 20:10
    关注

    As far as I've gone, I'm not sure Sarama handle the search of the broker version by itself.

    From my point of view, one need to define the API version you want to use in the config parameters of the Producer/Broker/Client like :

    config := sarama.NewConfig()
    config.Version=sarama.V0_10_2_0
    

    Also, Sarama does not support 0.11.0 yet (Sept 2017), so use 0.10.2.0 to access the latest API.

    Finaly, to use the second solution, edit the file Shopify/sarama/utils.go and add your versions at the end :

    V0_11_0_0  = newKafkaVersion(0, 11, 0, 0)
    V0_11_0  = newKafkaVersion(0, 11, 0, 0)
    minVersion = V0_11_0_0
    
    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能