本文基于A Guide To The Kafka Protocol文档,以及Spark Streaming中实现的org.apache.spark.streaming.kafka.KafkaCluster类.整理出Kafka中有关 Metadata API Produce API Fetch API Offset API(Aka ListOffset) Offset Commit/Fetch API Group Membership API Administrative API 零.准备工作 需
解析: 首先是读取字节: /** * 读取输入流中指定字节的长度 * <p/> * 输入流 * * @param length 指定长度 * @return 指定长度的字节数组 */ public static byte[] readBytesFromTo(byte[] buffer, int from, int length) { byte[] sub = new byte[length]; int cur = 0; for (int i = from; i < length + fr