Apache storm 暴风卡夫卡0.8加,我能从最新的偏移量读取吗?

Apache storm 暴风卡夫卡0.8加,我能从最新的偏移量读取吗?,apache-storm,Apache Storm,我有一个卡夫卡喷口的拓扑结构,有点像下面 SpoutConfig spoutConfig = new SpoutConfig(zkBrokerHosts, "some-topic","", "some-id"); spoutConfig.scheme = new SchemeAsMultiScheme(new StringScheme()); ... builder.setSpout("kafkaSpout",new KafkaSpout(spoutConfig),1); 当然,它工作得很好

我有一个卡夫卡喷口的拓扑结构,有点像下面

SpoutConfig spoutConfig = new SpoutConfig(zkBrokerHosts, "some-topic","", "some-id");
spoutConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
...

builder.setSpout("kafkaSpout",new KafkaSpout(spoutConfig),1);
当然,它工作得很好

考虑到我的拓扑失败并再次运行它的情况,我希望KafkaSpout从该主题的最新偏移量读取,而不是从消费者已读取的最后偏移量读取

有什么选择吗?我试过了

spoutConfig.startOffsetTime=System.currentTimeMillis();
但它似乎没有我想要的效果。卡夫卡诺和卡夫卡诺都没有强制开始时间(-2)


如果您有什么想法,请告诉我。

尝试
kafkanconfig.forceStartOffsetTime(-1)
<代码>-1表示最新的卡夫卡偏移量,代码>-2表示最早的可用偏移量

编辑:

此外,您可以使用相同的选项强制喷口从任何所需的偏移量开始消耗——只需传递数值偏移量作为唯一参数

忽略
forceStartOffsetTime
中的“
Time
”,参数名称有点混乱。卡夫卡中的偏移量是数字,与任何时间概念都没有联系<代码>-1只是告诉卡夫卡喷口从卡夫卡本身收集最新偏移量的一种特殊方式(idem
-2
表示最早可用偏移量)