Storm消费Kafka值得注意的坑

本文主要讨论了Storm在消费Kafka主题时遇到的问题,包括如何设置从Kafka的最早或最新消息开始消费,以及在故障恢复时如何依赖ZooKeeper中的offset信息。强调了重新部署时保持SpoutConfig.id不变以避免数据丢失或意外行为的重要性,并介绍了SpoutConfig中的关键配置参数及其作用。
摘要由CSDN通过智能技术生成
问题描述:
  kafka是之前早就搭建好的,新建的storm集群要消费kafka的主题,由于kafka中已经记录了很多消息,storm消费时从最开始消费

问题解决:

  下面是摘自官网的一段话:

How KafkaSpout stores offsets of a Kafka topic and recovers in case of failures
As shown in the above KafkaConfig properties, you can control from where in the Kafka topic the spout begins to read by setting KafkaConfig.startOffsetTime as follows:

kafka.api.OffsetRequest.EarliestTime(): read from the beginning of the topic (i.e. from the oldest messages onwards)
kafka.api.OffsetRequest.LatestTime(): read from the end of the topic (i.e. any new messsages that are being written to the topic)
A Unix timestamp aka seconds since the epoch (e.g. via System.currentTimeMil
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值