I have a Strimzi Kafka setup and try to connect to it with the following code:
from confluent_kafka import Consumer
c = Consumer({
"bootstrap.servers": "HOST:PORT",
'group.id':'GR',
'auto.offset.reset': 'earliest',
'enable.auto.commit': False,
'security.protocol': 'SASL_SSL',
'sasl.mechanisms': 'SCRAM-SHA-512',
'sasl.username': 'username',
'sasl.password': 'password',
'debug':'all'
})
c.subscribe(['topic'])
print("start...")
while True:
msg = c.poll(1.0)
if msg is None:
continue
if msg.error():
print("Consumer error: {}".format(msg.error()))
continue
print('Received message: {}'.format(msg.value().decode('utf-8')))
c.close()
With that code I do not receive ANY message.
With the kafka-python
library I receive all messages:
consumer = KafkaConsumer('topic',
group_id='GR',
bootstrap_servers='HOST:PORT',
enable_auto_commit=False,
auto_offset_reset='earliest',
value_deserializer=lambda x: x.decode('utf-8'),
security_protocol='SASL_SSL',
sasl_mechanism='SCRAM-SHA-512',
sasl_plain_username='username',
sasl_plain_password='password')
for message in consumer:
print(message)
Is confluent_kafka
not supporting Strimzi? What is wrong with my code?