private void manualEncodeVertxMessageBody(ActiveMQBuffer bodyBuffer, Object body, int type) {
   switch (type) {
     case VertxConstants.TYPE_BOOLEAN:
       bodyBuffer.writeBoolean(((Boolean) body));
       break;
     case VertxConstants.TYPE_BUFFER:
       Buffer buff = (Buffer) body;
       int len = buff.length();
       bodyBuffer.writeInt(len);
       bodyBuffer.writeBytes(((Buffer) body).getBytes());
       break;
     case VertxConstants.TYPE_BYTEARRAY:
       byte[] bytes = (byte[]) body;
       bodyBuffer.writeInt(bytes.length);
       bodyBuffer.writeBytes(bytes);
       break;
     case VertxConstants.TYPE_BYTE:
       bodyBuffer.writeByte((byte) body);
       break;
     case VertxConstants.TYPE_CHARACTER:
       bodyBuffer.writeChar((Character) body);
       break;
     case VertxConstants.TYPE_DOUBLE:
       bodyBuffer.writeDouble((double) body);
       break;
     case VertxConstants.TYPE_FLOAT:
       bodyBuffer.writeFloat((Float) body);
       break;
     case VertxConstants.TYPE_INT:
       bodyBuffer.writeInt((Integer) body);
       break;
     case VertxConstants.TYPE_LONG:
       bodyBuffer.writeLong((Long) body);
       break;
     case VertxConstants.TYPE_SHORT:
       bodyBuffer.writeShort((Short) body);
       break;
     case VertxConstants.TYPE_STRING:
     case VertxConstants.TYPE_PING:
       bodyBuffer.writeString((String) body);
       break;
     case VertxConstants.TYPE_JSON_OBJECT:
       bodyBuffer.writeString(((JsonObject) body).encode());
       break;
     case VertxConstants.TYPE_JSON_ARRAY:
       bodyBuffer.writeString(((JsonArray) body).encode());
       break;
     case VertxConstants.TYPE_REPLY_FAILURE:
       ReplyException except = (ReplyException) body;
       bodyBuffer.writeInt(except.failureType().toInt());
       bodyBuffer.writeInt(except.failureCode());
       bodyBuffer.writeString(except.getMessage());
       break;
     default:
       throw new IllegalArgumentException("Invalid body type: " + type);
   }
 }