String name = message.getDescriptorForType().getFullName();
int size = message.getSerializedSize();
ChannelBuffer buffer = new BigEndianHeapChannelBuffer(4 + name.length() + 1 + size + 4);
buffer.writeInt(name.length() + 1);
buffer.writeBytes(name.getBytes());
buffer.writeZero(1);
buffer.writeBytes(message.toByteArray());
Adler32 checksum = new Adler32();
checksum.update(buffer.array(), buffer.arrayOffset(), buffer.readableBytes());
buffer.writeInt((int) checksum.getValue());