def __init__(self, amqp_url, queue, handler, exchange=None, exchange_type=None, routing_key=None):
self._connection = None<EOL>"""<STR_LIT>"""<EOL>self._channel = None<EOL>self._consumer_tag = None<EOL>self._closing = False<EOL>self._handler = handler<EOL>self._queue = queue<EOL>self._url = amqp_url<EOL>if ((exchange or exchange_type or routing_key)<EOL>and not (exchange and exchange_type and routing_key)):<EOL><INDENT>raise RuntimeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>self._exchange = exchange<EOL>self._exchange_type = exchange_type<EOL>self._routing_key = routing_key<EOL>
Create a new instance of the consumer class, passing in the URL
        of RabbitMQ, the queue to listen to, and a callable handler that
        handles the events.

        The queue will be declared before consuming. If exchange, exchange_type,
        and routing_key are provided, it will also declare the exchange and bind
        the queue to it. Queue and exchange will be declared durable.

        :param str amqp_url: The AMQP url to connect with
        :param str queue: The queue to listen to
        :param function handler: The event handler that handles events
        :param str exchange: Optional name of exchange to declare
        :param str exchange_type: Optional type of exchange to declare
        :param str routing_key: Optional routing key of binding to create between exchange and queue