Esempio n. 1
0
def push_output(producer, topic_name, output, jobid, task_id,data):
    try:
        producer.push_data_to_queue(topic_name, output)
        log_info("push_output : producer flushed value on topic %s"%(topic_name), data)
    except Exception as e:
        response_custom = CustomResponse(Status.ERR_STATUS.value, jobid, task_id)
        log_exception("push_output : Response can't be pushed to queue %s"%(topic_name), data, None)
        raise KafkaProducerError(response_custom, "data Not pushed to queue: %s"%(topic_name))
Esempio n. 2
0
 def push_data_to_queue(self, topic_name, push_data, jobid, task_id):
     producer = self.producer_fn()
     try:
         producer.send(topic_name, value=push_data)
         producer.flush()
         log_info("push_data_to_queue",
                  "successfully pushed data to output queue", None)
     except:
         response_custom = CustomResponse(Status.ERR_STATUS.value, jobid,
                                          task_id)
         log_exception(
             "push_data_to queue",
             "Response can't be pushed to queue %s" % (topic_name), jobid,
             None)
         raise KafkaProducerError(
             response_custom.status_code,
             "data Not pushed to queue: %s" % (topic_name))