private Response dequeueMessage(ByteBuffer buffer) {
        int receiverId = buffer.getInt();
        int senderId = buffer.getInt();
        int queueId = buffer.getInt();
        int peekFlag = buffer.getInt();
        boolean peek = false;
        if (peekFlag == 1) {
            peek = true;
        }
        Message m;

        long startTime = System.nanoTime();

        _manager.startDBConnection();
        _manager.startDBTransaction();
        try {
            m = _manager.getMessageDao().dequeueMessage(receiverId, senderId, queueId, peek);
        } catch (MessageDequeueQueueDoesNotExistException e) {
            _manager.abortDBTransaction();
            return err(ERR_QUEUE_DOES_NOT_EXIST_EXCEPTION);
        } catch (MessageDequeueException e) {
            _manager.abortDBTransaction();
            return err(ERR_MESSAGE_DEQUEUE_EXCEPTION);
        } catch (MessageDequeueNotIntendedReceiverException e) {
            _manager.abortDBTransaction();
            return err(ERR_NO_MESSAGE_EXCEPTION);
        } catch (MessageDequeueEmptyQueueException e) {
            _manager.abortDBTransaction();
            return err(ERR_EMPTY_QUEUE_EXCEPTION);
        } finally {
            _manager.endDBTransaction();
            _manager.endDBConnection();
        }

        long stopTime = System.nanoTime();
        _EVALLOG5.log(startTime + "," + stopTime + ",DB_DEQUEUE_TOTAL");

        return ok(m);
    }