def _get_pika_channel_connection(self):
""" Connect to pika server and return channel and connection"""
parameters = pika.ConnectionParameters(host=self.host, port=self.port)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.exchange_declare(exchange=self.exchange)
channel.queue_declare(queue=self.queue_name, durable=True,
arguments={'x-message-ttl': self.expire_ms, })
channel.queue_bind(queue=self.queue_name,
exchange=self.exchange,
routing_key=self.exchange + '-' + self.queue_name)
return channel, connection
评论列表
文章目录