前言
本文是Kafka生产者架构篇的最后一篇文章。主要分析底层的读写操作。
源码分析
从read()、write()方法中,不难看出核心方法是调用nio原生的
ScatteringByteChannel#read(ByteBuffer)、GatheringByteChannel#write(ByteBuffer[])方法。
read()方法
核心方法是ScatteringByteChannel#read(ByteBuffer)
write()方法
核心方法是GatheringByteChannel#write(ByteBuffer[])