public void serialize(ByteBuffer buffer) {
        _LOGGER.log(Level.FINE, "Serializing response: " + _status + "/" + _errorCode);
        buffer.clear();
        buffer.putInt(_status);
        if(_status != STATUS_OK) {
            buffer.putInt(_errorCode);
            return;
        } else if(_message != null) {
            buffer.putInt(_message.getSender());
            buffer.putInt(_message.getReceiver());
            buffer.putInt(_message.getMessage().getBytes().length);
            buffer.put(_message.getMessage().getBytes());
        }
        else if (_waitingQueues != null) {
            int size = _waitingQueues.size();
            buffer.putInt(size);
            for (int waitingQueueId : _waitingQueues) {
                buffer.putInt(waitingQueueId);
            }
        }
    }