public static RoutingMessage getRoutingMessage(ByteBuffer buffer) {
        int headerSize = buffer.getInt();

        // header
        Map<String, String> header = null;
        if (headerSize > 0) {
            header = new HashMap<>();
            for (int i = 0; i < headerSize; i++) {
                String key = readString(buffer);
                String value = readString(buffer);
                header.put(key, value);
            }
        }
        //body
        int bodyLen = buffer.getInt();
        byte[] bodyMessage = new byte[bodyLen];
        buffer.get(bodyMessage);

        //tags
        int tagLen = buffer.getInt();
        String[] tags = new String[tagLen];
        for (int i = 0; i < tagLen; i++) {
            tags[i] = readString(buffer);
        }

        return new RoutingMessage(header, bodyMessage, tags);
    }