diff --git a/rc_rmq.py b/rc_rmq.py index 788387c4f00b7828d69c8cc1e0a88159b127900f..37afa3f44f872454a3b96fccf2d5a6a538fe01cf 100644 --- a/rc_rmq.py +++ b/rc_rmq.py @@ -65,11 +65,11 @@ class RCRMQ(object): exchange_type=self.EXCHANGE_TYPE, durable=True) - if self.QUEUE is not None: - self._channel.queue_declare(queue=self.QUEUE, durable=self.DURABLE) - self._channel.queue_bind(exchange=self.EXCHANGE, - queue=self.QUEUE, - routing_key=self.ROUTING_KEY) + def bind_queue(self): + self._channel.queue_declare(queue=self.QUEUE, durable=self.DURABLE) + self._channel.queue_bind(exchange=self.EXCHANGE, + queue=self.QUEUE, + routing_key=self.ROUTING_KEY) def disconnect(self): self._channel.close() @@ -103,6 +103,8 @@ class RCRMQ(object): if self._connection is None: self.connect() + self.bind_queue() + self._consumer_tag = self._channel.basic_consume(self.QUEUE,obj['cb']) self._consuming = True try: