'Reconnect to rabbitmq server'

def reconnect(self):

    import pika
    import pika.exceptions
    self.connection = pika.BlockingConnection(pika.URLParameters(self.amqp_url))
    self.channel = self.connection.channel()
    try:
        self.channel.queue_declare(self.name)
    except pika.exceptions.ChannelClosed:
        self.connection = pika.BlockingConnection(pika.URLParameters(self.amqp_url))
        self.channel = self.connection.channel()
