producer_consumer_parse_recipes_2.py 294 B

1234567891011
  1. def connect_kafka_producer():
  2. _producer = None
  3. try:
  4. _producer = KafkaProducer(bootstrap_servers=['localhost:9092'], api_version=(0, 10))
  5. except Exception as ex:
  6. print('Exception while connecting Kafka')
  7. print(str(ex))
  8. finally:
  9. return _producer