khen | b95fe9a | 2016-10-05 11:15:25 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | import threading, logging, time |
| 3 | |
| 4 | from kafka import KafkaConsumer |
| 5 | |
khen | b95fe9a | 2016-10-05 11:15:25 -0700 | [diff] [blame] | 6 | class Consumer(threading.Thread): |
| 7 | daemon = True |
| 8 | |
| 9 | def run(self): |
Khen Nursimulu | b99f083 | 2016-10-05 11:20:17 -0700 | [diff] [blame] | 10 | consumer = KafkaConsumer(bootstrap_servers='10.100.198.220:9092', |
khen | b95fe9a | 2016-10-05 11:15:25 -0700 | [diff] [blame] | 11 | auto_offset_reset='earliest') |
| 12 | consumer.subscribe(['voltha-heartbeat']) |
| 13 | |
| 14 | for message in consumer: |
| 15 | print (message) |
| 16 | |
| 17 | |
| 18 | def main(): |
| 19 | threads = [ |
| 20 | Consumer() |
| 21 | ] |
| 22 | |
| 23 | for t in threads: |
| 24 | t.start() |
| 25 | |
| 26 | time.sleep(3000) |
| 27 | |
| 28 | if __name__ == "__main__": |
khen | b95fe9a | 2016-10-05 11:15:25 -0700 | [diff] [blame] | 29 | main() |
| 30 | |