kafka consumer
This commit is contained in:
parent
8bab3d9116
commit
31405d08bc
@ -1,3 +1,21 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from kafka import KafkaConsumer
|
||||||
|
|
||||||
|
|
||||||
|
DATETIMES=[]
|
||||||
|
|
||||||
|
|
||||||
|
consumer = KafkaConsumer(bootstrap_servers='localhost:9092', auto_offset_reset='earliest', consumer_timeout_ms=1000)
|
||||||
|
consumer.subscribe(['test'])
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
for message in consumer:
|
||||||
|
DATETIMES.append(datetime.now())
|
||||||
|
consumer.close()
|
||||||
|
except Exception:
|
||||||
|
consumer.close()
|
||||||
|
print(DATETIMES)
|
||||||
|
Loading…
Reference in New Issue
Block a user