1.v0消息格式

官网地址:http://kafka.apache.org/090/documentation.html#messages

Messages consist of a fixed-size header and variable length opaque byte array payload. The header contains a format version and a CRC32 checksum to detect corruption or truncation. Leaving the payload opaque is the right decision: there is a great deal of progress being made on serialization libraries right now, and any particular choice is unlikely to be right for all uses. Needless to say a particular application using Kafka would likely mandate a particular serialization type as part of its usage. The MessageSet interface is simply an iterator over messages with specialized methods for bulk reading and writing to an NIO Channel.

/*** A message. The format of an N byte message is the following:** If magic byte is 0** 1. 1 byte "magic" identifier to allow format changes** 2. 4 byte CRC32 of the payload** 3. N - 5 byte payload** If magic byte is 1** 1. 1 byte "magic" identifier to allow format changes** 2. 1 byte "attributes" identifier to allow annotations on the message independent of the version (e.g. compression enabled, type of codec used)** 3. 4 byte CRC32 of the payload** 4. N - 6 byte payload**/

2.v1消息格式

官网地址:http://kafka.apache.org/0100/documentation.html#messages

 /*** 1. 4 byte CRC32 of the message* 2. 1 byte "magic" identifier to allow format changes, value is 0 or 1* 3. 1 byte "attributes" identifier to allow annotations on the message independent of the version*    bit 0 ~ 2 : Compression codec.*      0 : no compression*      1 : gzip*      2 : snappy*      3 : lz4*    bit 3 : Timestamp type*      0 : create time*      1 : log append time*    bit 4 ~ 7 : reserved* 4. (Optional) 8 byte timestamp only if "magic" identifier is greater than 0* 5. 4 byte key length, containing length K* 6. K byte key* 7. 4 byte payload length, containing length V* 8. V byte payload*/

3.v2消息格式

官网地址:http://kafka.apache.org/0110/documentation.html#messageformat

Messages (aka Records) are always written in batches. The technical term for a batch of messages is a record batch, and a record batch contains one or more records. In the degenerate case, we could have a record batch containing a single record. Record batches and records have their own headers. The format of each is described below for Kafka version 0.11.0 and later (message format version v2, or magic=2). Click here for details about message formats 0 and 1.

baseOffset: int64
batchLength: int32
partitionLeaderEpoch: int32
magic: int8 (current magic value is 2)
crc: int32
attributes: int16bit 0~2:0: no compression1: gzip2: snappy3: lz4bit 3: timestampTypebit 4: isTransactional (0 means not transactional)bit 5: isControlBatch (0 means not a control batch)bit 6~15: unused
lastOffsetDelta: int32
firstTimestamp: int64
maxTimestamp: int64
producerId: int64
producerEpoch: int16
baseSequence: int32
records: [Record]

kafka消息存储格式相关推荐

  1. kafka消息会不会丢失

    转载:https://baijiahao.baidu.com/s?id=1583469327946027281&wfr=spider&for=pc 消息发送方式 想清楚Kafka发送的 ...

  2. Kafka 消息监控 - Kafka Eagle

    1.概述 在开发工作当中,消费 Kafka 集群中的消息时,数据的变动是我们所关心的,当业务并不复杂的前提下,我们可以使用 Kafka 提供的命令工具,配合 Zookeeper 客户端工具,可以很方便 ...

  3. kudu接受kafka消息_Kafka入门详解

    1.1 什么是kafka? Kafka最初由Linkedin公司开发,是一个分布式.支持分区的(partition).多副本的(replica),基于zookeeper协调的分布式消息系统,它的最大的 ...

  4. go 实现 kafka 消息发送、接收

    引言 网络上关于 go 实现 kafka 消息发送和接收的文章很多,但是实际操作起来又不是很清楚,本文在网络资源的基础上,结合自己搭建过程中遇到的问题进行了总结. 本文的实验主机:Mac笔记本. 一. ...

  5. tcp前4字节消息长度_RocketMQ的消息存储格式

    总体代码 我们可以通过阅读RocketMQ的消息存储代码来了解RocketMQ的消息存储格式,消息的存储入口是DefaultMessageStore,我们可以通过DefaultMessageStore ...

  6. kafka消息的分发与消费(一)

    关于 Topic 和 Partition: Topic: 在 kafka 中,topic 是一个存储消息的逻辑概念,可以认为是一个消息集合.每条消息发送到 kafka 集群的消息都有一个类别.物理上来 ...

  7. Apache Kafka消息格式的演变(0.7.x~0.10.x)

    用 Kafka 这么久,从来都没去了解 Kafka 消息的格式.今天特意去网上搜索了以下,发现这方面的资料真少,很多资料都是官方文档的翻译:而且 Kafka 消息支持压缩,对于压缩消息的格式的介绍更少 ...

  8. Kafka整体结构图、Consumer与topic关系、Kafka消息分发、Consumer的负载均衡、Kafka文件存储机制、Kafka partition segment等(来自学习资料)

    ##1. Kafka整体结构图 Kafka名词解释和工作方式  Producer : 消息生产者,就是向kafka broker发消息的客户端.  Consumer : 消息消费者,向kafka ...

  9. 使用PHP处理Kafka消息

    Kafka 是一种高吞吐的分布式消息系统,能够替代传统的消息队列用于解耦合数据处理,缓存未处理消息等,同时具有更高的吞吐率,支持分区.多副本.冗余,因此被广泛用于大规模消息数据处理应用. Kafka的 ...

最新文章

  1. eax ax ah al
  2. 解决问题ImportError: HDFStore requires PyTables, quot;No module named 'tables'quot; problem importing
  3. 图像降噪算法——图像噪声模型
  4. P2831-愤怒的小鸟【状压dp】
  5. LLVM和clang
  6. C++难吗?好学吗?C++到底怎么样?
  7. 2018-2019-2 网络对抗技术 20165301 Exp 9 Web安全基础
  8. 【VulnHub靶场】——HARRYPOTTER第二部: NAGINI
  9. 【SpringMVC】——图解执行流程
  10. 小猪短租网一个网页上的单个价格
  11. 2016年计算机二级步骤,2016计算机二级MS-Office真题15操作步骤
  12. asp.net打开新标签页
  13. 编辑视频贴纸软件_3招教你搞定怎么在视频上加贴纸,剪片必备的手机App!
  14. untiy virtual reality supported勾选
  15. FastQC原始安装
  16. 用深度学习创作艺术绘画
  17. 【bzoj1778】[Usaco2010 Hol]Dotp 驱逐猪猡 矩阵乘法+概率dp+高斯消元
  18. 桌面上 计算机 回收站不见了怎么办,桌面上的回收站图标不见了怎么办
  19. 普罗米修斯?对!就是 Prometheus ,如何计算 P90 / P99 ? 准确评控服务耗时性能!
  20. 【HTML】HTML网页设计----模仿汉服前端设计

热门文章

  1. Mongodb系列- java客户端简单使用(CRUD)
  2. HDwiki 6.0 图片大图不能正常显示的解决方法
  3. 自己动手写编译器、链接器目录结构
  4. raspberrypi 与 arduino 使用 nRF24L01+ 通信 -- raspberry pi为发送端
  5. 利用 PicGo 实现 MarkDown 自动上传图片
  6. Nodejs Set和Map的使用
  7. [Node.js] mySQL数据库 -- 数据库的基本操作
  8. 初读JavaScript DOM编程艺术(一)
  9. vue2.0-脚手架-todolist案例
  10. C/C++数组名与指针区别