卡夫卡:抵消序列

编程入门 行业动态 更新时间:2024-10-22 07:41:07
本文介绍了卡夫卡:抵消序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否将为每个发布的消息(假设消息已压缩)分配一个唯一的偏移号,并在给定分区内保持顺序和递增?另外,offset#序列是否有可能会重置自身,也就是说它可以从0开始?

解决方案

每个分区是一个有序的,不可变的记录序列,即连续附加到-结构化提交日志.记录在每个分区都分配有一个顺序ID号,称为偏移量唯一地标识分区中的每个记录.

消费者甚至可以从一开始就读取特定的偏移量:

要为特定消费者组重置偏移量,可以使用以下命令:

kafka-consumer-groups --bootstrap-server localhost:9092 --group my-group --reset-offsets-最早--all-topics --execute

Will each message posted (assuming messages are compressed) have a unique offset# assigned and remain sequential and incremental within a given partition? Also, is it possible that the offset# sequence can reset itself, meaning it can start from 0?

解决方案

Official documentation is quite clear on that:

For each topic, the Kafka cluster maintains a partitioned log that looks like this:

Each partition is an ordered, immutable sequence of records that is continually appended to—a structured commit log. The records in the partitions are each assigned a sequential id number called the offset that uniquely identifies each record within the partition.

Consumers are able to read from specific offsets even from the beginning:

In order to reset offsets for a particular consumer group you can use the following:

kafka-consumer-groups --bootstrap-server localhost:9092 --group my-group --reset-offsets --to-earliest --all-topics --execute

更多推荐

卡夫卡:抵消序列

本文发布于:2023-11-26 00:31:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631939.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:序列   卡夫卡

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!