I created a AWS MSK instance with two brokers. I can use that to produce and consume messages by using kafka#s shell commands (kafka-console-producer.sh
and kafka-console-consumer.sh
) but the problem is, it is not working with kafka python library.
consumer = KafkaConsumer(
bootstrap_servers=["address_of_broker_1:9092","address_of_broker_1:9092"],
auto_offset_reset='latest',
enable_auto_commit=True,
api_version=(2,0,2),
group_id='group8',
fetch_max_wait_ms=5)
consumer.subscribe(['test1'])
for msg in consumer:
print(msg)
This does not work because,
sudo sh kafka-consumer-groups.sh --bootstrap-server address_of_broker1:9092,address_of_broker2:9092 --list --all-groups
this only show 2 default consumer
amazon.msk.canary.group.broker-1
amazon.msk.canary.group.broker-2
whereas, when I use kafka-console-consumer.sh
is show a newly added consumer in the list.
Problem is, the python code does not show any error message. Which is why I am completely clueless.
Can anybody give me a clue what might be happening or where can I see the error log in AWS MSK