def fancy_retrieve(broker, num_messages=1):
    """
    Fancy wrapper that combines several operations to retrieve a message from the message broker.

    :param broker:
        The Broker instance
    :param num_messages:
        The number of messages to retrieve from the queue
    :rtype:
        list
    :return:
        The list of messages kept in the internal message buffer
    """
    broker.connect()
    broker.subscribe()
    messages = broker.pop_messages(num_messages)
    broker.disconnect()
    return messages