in netty-custom-correlation/src/main/java/org/apache/camel/example/netty/MyCodecEncoder.java [33:49]
protected void encode(ChannelHandlerContext channelHandlerContext, Object message, ByteBuf byteBuf) throws Exception {
byte[] body;
if (message instanceof String) {
body = ((String) message).getBytes();
} else if (message instanceof byte[]) {
body = (byte[]) message;
} else {
throw new IllegalArgumentException("The message to encode is not a supported type: "
+ message.getClass().getCanonicalName());
}
byteBuf.writeByte(startByte);
byteBuf.writeBytes(body);
byteBuf.writeByte(endByte1);
byteBuf.writeByte(endByte2);
}