Fix connections
This commit is contained in:
@@ -16,7 +16,6 @@ import io
|
||||
import zlib
|
||||
import os.path
|
||||
import requests
|
||||
from .reqs_graphql import get_catalog, get_object
|
||||
import xml.etree.ElementTree as ET
|
||||
from .reqs.request_xml_service import RequestXmlService
|
||||
import zipfile
|
||||
@@ -347,6 +346,22 @@ def pika_task():
|
||||
channel_itv.start_consuming()
|
||||
|
||||
|
||||
def status_callback(ch, method, properties, body):
|
||||
status_info = json.loads(body)
|
||||
if status_info['status'] == 'connected':
|
||||
connected.add(status_info['bnd_name'])
|
||||
elif status_info['status'] == 'disconnected':
|
||||
connected.remove(status_info['bnd_name'])
|
||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||
|
||||
|
||||
def status_task():
|
||||
connection = pika.BlockingConnection(pika.URLParameters(Config.rabbit_conn))
|
||||
channel_status = connection.channel()
|
||||
channel_status.basic_consume(queue=Config.rabbit_status_queue, on_message_callback=status_callback)
|
||||
channel_status.start_consuming()
|
||||
|
||||
|
||||
def pika_itv_callback(ch, method, properties, body):
|
||||
try:
|
||||
data = json.loads(body)
|
||||
@@ -564,6 +579,9 @@ def main():
|
||||
pika_thread = threading.Thread(target=pika_task)
|
||||
pika_thread.start()
|
||||
|
||||
status_thread = threading.Thread(target=status_task)
|
||||
status_thread.start()
|
||||
|
||||
pika_itv_task()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user