有什么方法我只能从旧的偏移中寻找1条消息吗?

时间:2017-04-03 23:21:22

标签: apache-kafka spring-kafka

我想知道有什么方法我只能从旧的偏移中寻找1条消息吗?因为我只想重新处理1条消息。

1 个答案:

答案 0 :(得分:2)

您应该实施ConsumerSeekAware并在其中:

/**
 * When using group management, called when partition assignments change.
 * @param assignments the new assignments and their current offsets.
 * @param callback the callback to perform an initial seek after assignment.
 */
void onPartitionsAssigned(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback);

对所需的-1执行所需的partition,其offset作为该assignments地图的值。