public Message getMessage(int queueId, int senderId, boolean peek) throws MessageDequeueException, MessageDequeueQueueDoesNotExistException, MessageDequeueEmptyQueueException, MessageDequeueNotIntendedReceiverException {
        try {
            _out.writeInt(20); //Size
            _out.writeInt(Response.MSG_QUEUE_DEQUEUE);
            _out.writeInt(_clientId); //Receiver
            _out.writeInt(senderId); //Particular sender
            _out.writeInt(queueId); //Queue
            if (peek) {
                _out.writeInt(1);
            }
            else {
                _out.writeInt(0);
            }
            _out.flush();

            int messageType = _in.readInt();
            if(messageType != Response.STATUS_OK) {
                int errorCode = _in.readInt();
                if(errorCode == Response.ERR_MESSAGE_DEQUEUE_EXCEPTION) {
                    throw new MessageDequeueException(new Exception());
                } else if(errorCode == Response.ERR_QUEUE_DOES_NOT_EXIST_EXCEPTION) {
                    throw new MessageDequeueQueueDoesNotExistException(new Exception());
                } else if(errorCode == Response.ERR_EMPTY_QUEUE_EXCEPTION) {
                    throw new MessageDequeueEmptyQueueException(new Exception());
                } else if(errorCode == Response.ERR_NO_MESSAGE_EXCEPTION) {
                    throw new MessageDequeueNotIntendedReceiverException(new Exception());
                }
            }

            int sender = _in.readInt();
            int receiver = _in.readInt();
            int msgLength = _in.readInt();
            byte[] msg = new byte[msgLength];
            _in.read(msg, 0, msgLength);

            //Create object
            Message message = new Message(sender, receiver, new String(msg));
            return message;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }