-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsumer.py
More file actions
32 lines (24 loc) · 726 Bytes
/
consumer.py
File metadata and controls
32 lines (24 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from confluent_kafka import Consumer
kafka_advanced_listener = 'PLAINTEXT://localhost:29092'
topic_name = 'my_topic'
c = Consumer(
{
'bootstrap.servers': kafka_advanced_listener,
'group.id': 'mygroup',
'auto.offset.reset': 'earliest'
}
)
c.subscribe([topic_name])
while True:
msg = c.poll(5.0)
if msg == None:
continue
if msg.error():
print(f"Consumer error: {msg.error()}")
continue
print(f"Received message: {msg.value().decode('utf-8')}, {msg.partition()}")
"""
msg.headers(), msg.key(), msg.latency(), msg.offset(), msg.timestamp(), msg.topic(),
msg.len() -> bir tek bu fonksiyon çalışmadı anlamadım.
"""
c.close()