-1

I am encountering the following error:

Traceback (most recent call last):
connection = KafkaProducer(kafka_settings['topic'], bootstrap_servers=kafka_settings['bootstrap_servers'])
TypeError: __init__() takes 1 positional argument but 2 were given

This is strange to me because I followed the documentation given. https://kafka-python.readthedocs.io/en/master/usage.html

How do I resolve this?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
morhc
  • 194
  • 11
  • I'm looking at the docs now, and the topic name parameter doesn't exist when you initialize a producer – OneCricketeer Oct 21 '21 at 13:54
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 21 '21 at 13:57

1 Answers1

1

https://kafka-python.readthedocs.io/en/master/usage.html suggest that bootstrap_servers is parameter given during creating KafkaProducer, but topic should be specified when using .send method, please try following

connection = KafkaProducer(bootstrap_servers=kafka_settings['bootstrap_servers'])
future = connection.send(kafka_settings['topic'], b'your_message_here')
Daweo
  • 31,313
  • 3
  • 12
  • 25