Unable send and read msg from python

from confluent_kafka import Consumer, KafkaError
import logging

logging.basicConfig(level=logging.DEBUG)

conf = {
‘bootstrap.servers’: ‘ip:9092’,
‘group.id’: ‘test-consumer89-grokkkup’,
‘enable.auto.commit’: True,
‘auto.offset.reset’: ‘earliest’
}

consumer = Consumer(conf)
consumer.subscribe([‘study1’])

while True:
msg = consumer.poll(1.0)

if msg is None:
    continue

if msg.error():
    if msg.error().code() == KafkaError._PARTITION_EOF:
        print('End of partition reached')
    else:
        print('Error while consuming message: {}'.format(msg.error()))
else:
    print('Received message: {}'.format(msg.value().decode('utf-8')))

using this code I am unable to consume msg . connetion is accepted but not getting any msg even in topic msg is there

Kafka Streams is not the right space for your question. It’s about Kafka’s Java stream processing library: Apache Kafka

You should try Non-Java Clients - Confluent Community to get help.

1 Like