My Plan is to have a message protocol as outlined below:
MessageLength: integer with total message lengthMessageID: integer with auto incrementing identifierMessageType: integer (enum) with the type of messagePayload:byte[]with the Payload of the message (Serialised POJO)
At the moment I just am looking at making sure I create the ByteBuf in the correct and optimal way. At this stage I have the following:
io.netty.buffer.ByteBuf buf = Unpooled.buffer(); // Test Data Class TestData test = new TestData("FirstName", "LastName", 40); // Convert to Bytes is method to return the Byte Array (Serialised POJO) byte[] payload = convertToBytes(test); // Write 1 simulating MessageID 1 buf.writeInt(1); // Write 2 simulating MessageType of 2 buf.writeInt(2); // Write The Payload data<BR> buf.writeBytes(payload); The goal would be to them pass on to a LengthFieldPrepender and up the pipeline.
Is this the right way to create the ByteBuf? Or is there a better way?