【问题标题】:Apache storm and kafka: how can I get the consumer object of a kafka spout such that I can log its offset?Apache Storm 和 kafka:如何获取 kafka spout 的消费者对象,以便记录其偏移量?
【发布时间】:2018-07-25 03:44:10
【问题描述】:

我正在使用 apachestorm-core 0.9.6(它很旧,由于遗留问题,无法对其采取任何措施)KafkaSpout。如果我可以记录元组偏移量,那么调试我面临的一些反序列化问题将非常有帮助。

到目前为止,我已经看到storm.kafka.KafkaUtils 有两种方法:

public static long getOffset(SimpleConsumer consumer, String topic, int partition, KafkaConfig config) 
public static long getOffset(SimpleConsumer consumer, String topic, int partition, long startOffsetTime) 

第一个是第二个的包装器。在我看来,我唯一不知道如何调用这个函数的是consumer。我已经阅读了KafkaSpout 代码,但无法弄清楚如何从中获取 kafka 消费者。

【问题讨论】:

    标签: apache-kafka apache-storm


    【解决方案1】:

    如果您查看storm-kafka 代码,您可以在获取消息https://github.com/apache/storm/blob/v0.9.6/external/storm-kafka/src/jvm/storm/kafka/PartitionManager.java#L162 之后执行您需要的任何日志记录。您可以自己构建修改版的storm-kafka,并将构建工具指向您自己的副本。

    【讨论】:

    • 感谢您的指点。我会阅读代码,看看我是否能弄清楚。
    猜你喜欢
    • 1970-01-01
    • 2013-12-26
    • 1970-01-01
    • 1970-01-01
    • 2017-01-01
    • 2016-03-11
    • 2017-03-09
    • 2019-05-01
    • 2017-07-22
    相关资源
    最近更新 更多