Esempio n. 1
0
def reset_backlog(input_queue):
    try:
        with input_queue.mutex:
            input_queue.queue.clear()
            event_logger.warn('Items in Input queue have been cleared.')
    except Exception, e:
        event_logger.error('Queue reset failed. Exception - ' + e.message)
Esempio n. 2
0
def clear_queue_items():
    try:
        reset_backlog(input_queue)

        global stats_thrd
        if stats_thrd is not None:
            stats_thrd.do_task()
    except Exception, e:
        event_logger.error('Error while clearing items. Exception-' +
                           e.message)
 def failed_data(self, data, exception_message):
     try:
         publish_queue.put({
             'ackMsg': True,
             'deliveryTag': data['deliveryTag'],
             'msgProperties': data['msgProperties'],
             'data': data['data'],
             'exchange': settings.EXCHANGE_FAILED_POSTING,
             'routingKey': settings.FAILED_POSTING_KEY,
             'retryAttempt': 0,
             'MessageTime': time.time()
         })
     except Exception, e:
         event_logger.error('Exception-' + str(e))
         return False
    def Convert_Data(self, message):
        try:
            if message == None or len(message) == 0:
                raise Exception('Message is empty')

            data = (ET.fromstring(message))
            intermediary_data = ET.tostring(data, encoding='iso-8859-1', method='xml')

            #Transform Xml data to JSON
            json_convert = xmltodict.parse(intermediary_data)
            event_logger.debug('Data conversion to json is successful.')

            return json_convert
        except Exception, e:
            event_logger.error('Error while converting data to json. Exception-'+str(e))
            raise e
Esempio n. 5
0
        global stats_thrd
        stats_thrd = TaskThread(
            settings.STATS_EVENT_TIME_SEC
        )  # Instantiate a thread to track message counters
        stats_thrd.daemon = True
        stats_thrd.start()
        event_logger.info('Statistics logging thread initiated')

        while True:  # Maintain main thread alive
            time.sleep(
                30
            )  # This will never be triggered; since acknowledge module has infinite loop

    except KeyboardInterrupt, k:
        clear_queue_items()
        event_logger.warn('Keyboard Interrupt; Aborting process. ' + str(k))
        print('Keyboard Interrupt. Aborting process')

    except Exception, e:
        clear_queue_items()
        event_logger.error('Error occurred in main thread. Exception-' +
                           str(e))
        print('Error occurred in main thread. Exception-' + str(e))


if __name__ == '__main__':
    print '[*] Initiating message process. To exit press CTRL+C'
    main()

event_logger.info("Data Converter Shutdown Complete.")