JsonObject jsonObject;
byte[] data;
// Parse the byte[] message body
try {
Buffer body = message.body();
if (body.length() == 0) {
chunksStatsBean.incrementWriteErrorCount();
sendError(message, "message body is empty");
return;
}
// First four bytes indicate the json string length
int len = body.getInt(0);
// Decode json
int from = 4;
byte[] jsonBytes = body.getBytes(from, from + len);
jsonObject = new JsonObject(decode(jsonBytes));
// Remaining bytes are the chunk to be written
from += len;
data = body.getBytes(from, body.length());
} catch (RuntimeException e) {
chunksStatsBean.incrementWriteErrorCount();
sendError(message, "error parsing buffer message. see the documentation for the correct format", e);
return;