use same rabittmq connection
This commit is contained in:
@@ -1,24 +1,19 @@
|
||||
import logging
|
||||
import threading
|
||||
from datetime import datetime
|
||||
|
||||
import pika
|
||||
from params import rabittmq_connection
|
||||
|
||||
APPOINTMENT_QUEUE = "APPOINTMENT_QUEUE"
|
||||
|
||||
|
||||
class MessageReceiver:
|
||||
def __init__(self):
|
||||
self._credentials = pika.PlainCredentials('scrapy_rabbitmq', '4x!hReCbA5v3heKWfPJV-Y')
|
||||
|
||||
def start_listener(self, callback):
|
||||
t = threading.Thread(target=self._run, args=(callback,))
|
||||
t.start()
|
||||
|
||||
def _run(self, callback):
|
||||
connection = pika.BlockingConnection(
|
||||
pika.ConnectionParameters(host='rabbitmq.lpaconsulting.fr', port=6672, credentials=self._credentials))
|
||||
channel = connection.channel()
|
||||
|
||||
channel = rabittmq_connection.channel()
|
||||
channel.queue_declare(queue=APPOINTMENT_QUEUE)
|
||||
channel.basic_consume(queue=APPOINTMENT_QUEUE,
|
||||
auto_ack=True,
|
||||
|
||||
Reference in New Issue
Block a user