d: cd D:\kafka_2.12-2.5.0\bin\windows zookeeper-server-start.bat D:\kafka_2.12-2.5.0\config\zookeeper.properties
d: cd D:\kafka_2.12-2.5.0\bin\windows kafka-server-start.bat D:\kafka_2.12-2.5.0\config/server.properties
d: cd D:\kafka_2.12-2.5.0\bin\windows kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test kafka-topics.bat --list --bootstrap-server localhost:9092
d: cd D:\kafka_2.12-2.5.0\bin\windows kafka-console-producer.bat --bootstrap-server localhost:9092 --topic testctrl+c襯 襯企 螳, 蠏碁 .
d: cd D:\kafka_2.12-2.5.0\bin\windows kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning
pip install kafka-python
from kafka import KafkaConsumer import sys bootstrap_servers = ["localhost:9092"] topicName = 'test' consumer = KafkaConsumer(topicName, group_id='group1', bootstrap_servers=bootstrap_servers, auto_offset_reset='earliest') for message in consumer: print(message.value) ''' try: for message in consumer: #print ("%s:%d:%d: key=%s value=%s" % (message.topic, message.partition,message.offset, message.key,message.value)) print(message.value) except KeyboardInterrupt: sys.exit() '''