def _listen_to_queue_with_callback(callback, queue_name): from osis_common.queue import queue_listener try: queue_listener.SynchronousConsumerThread( settings.QUEUES.get('QUEUES_NAME').get(queue_name), callback).start() except (ConnectionClosed, ChannelClosed, AMQPConnectionError, ConnectionError) as e: LOGGER.exception("Couldn't connect to the QueueServer")
print("Check the following possible causes :") print(" - The DJANGO_SETTINGS_MODULE defined in your .env doesn't exist") print( " - No DJANGO_SETTINGS_MODULE is defined and the default 'backoffice.settings.local' doesn't exist " ) sys.exit("DjangoSettingsError") from django.conf import settings LOGGER = logging.getLogger(settings.DEFAULT_LOGGER) if hasattr(settings, 'QUEUES') and settings.QUEUES: from osis_common.queue import queue_listener, callbacks # migration queue used to migrate data between osis ans osis_portal try: queue_listener.SynchronousConsumerThread( settings.QUEUES.get('QUEUES_NAME').get('MIGRATIONS_TO_CONSUME'), callbacks.process_message).start() except (ConnectionClosed, ChannelClosed, AMQPConnectionError, ConnectionError) as e: LOGGER.exception("Couldn't connect to the QueueServer") # Queue in which are sent scores sheets json data # This queue is used only if assessments module is installed if 'assessments' in settings.INSTALLED_APPS: from assessments.views.score_encoding import send_json_scores_sheets_to_response_queue try: queue_listener.SynchronousConsumerThread( settings.QUEUES.get('QUEUES_NAME').get( 'SCORE_ENCODING_PDF_REQUEST'), send_json_scores_sheets_to_response_queue).start() except (ConnectionClosed, ChannelClosed, AMQPConnectionError,
print( " - No DJANGO_SETTINGS_MODULE is defined and the default 'frontoffice.settings.local' doesn't exist " ) sys.exit("DjangoSettingsError") from performance.queue.student_performance import callback as perf_callback, update_exp_date_callback from django.conf import settings LOGGER = logging.getLogger(settings.DEFAULT_LOGGER) if hasattr(settings, 'QUEUES') and settings.QUEUES: from osis_common.queue import queue_listener as common_queue_listener, callbacks as common_callback # migration queue used to migrate data between osis ans osis_portal try: common_queue_listener.SynchronousConsumerThread( settings.QUEUES.get('QUEUES_NAME').get('MIGRATIONS_TO_CONSUME'), common_callback.process_message).start() except (ConnectionClosed, ChannelClosed, AMQPConnectionError, ConnectionError) as e: LOGGER.exception("Couldn't connect to the QueueServer") # Queues used by performance app if 'performance' in settings.INSTALLED_APPS: # Thread in which is running the listening of the queue used to received student points try: common_queue_listener.SynchronousConsumerThread( settings.QUEUES.get('QUEUES_NAME').get('PERFORMANCE'), perf_callback).start() except (ConnectionClosed, ChannelClosed, AMQPConnectionError, ConnectionError) as e: LOGGER.exception("Couldn't connect to the QueueServer")
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../frontoffice') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "frontoffice.settings") application = get_wsgi_application() from osis_common.queue import queue_listener as common_queue_listener, callbacks as common_callback from performance.queue.student_performance import callback as perf_callback, update_exp_date_callback from django.conf import settings LOGGER = logging.getLogger(settings.DEFAULT_LOGGER) if hasattr(settings, 'QUEUES'): # Thread in which is running the listening of the queue used to migrate data (from Osis to Osis-portal) try: common_queue_listener.SynchronousConsumerThread( settings.QUEUES.get('QUEUES_NAME').get('MIGRATIONS_TO_CONSUME'), common_callback.process_message).start() except (ConnectionClosed, ChannelClosed, AMQPConnectionError, ConnectionError) as e: LOGGER.exception("Couldn't connect to the QueueServer") # Thread in which is running the listening of the queue used to received student points try: common_queue_listener.SynchronousConsumerThread( settings.QUEUES.get('QUEUES_NAME').get('PERFORMANCE'), perf_callback).start() except (ConnectionClosed, ChannelClosed, AMQPConnectionError, ConnectionError) as e: LOGGER.exception("Couldn't connect to the QueueServer") # Thread in wich is running the listening of the queue used to update the expiration date of the students points