Python

confluent kafka

Kyle79 2021. 9. 17. 15:08

 

 

https://www.confluent.io/blog/introduction-to-apache-kafka-for-python-programmers/?utm_medium=sem&utm_source=google&utm_campaign=ch.sem_br.brand_tp.prs_tgt.confluent-brand_mt.mbm_rgn.apac_lng.eng_dv.all_con.confluent-python&utm_term=%2Bconfluent%20%2Bpython&creative=&device=c&placement=&gclid=Cj0KCQjw1ouKBhC5ARIsAHXNMI9W1SnTGyAdPKPPQof4PprZhrs-n7woxaHJEPQMhthz1bW14rwsxlYaAh9wEALw_wcB 

 

Introduction to Apache Kafka® for Python Programmers | Confluent

In this blog post, we're going to get back to basics and walk through how to get started using Apache Kafka with your Python applications.

www.confluent.io

 

 

 

https://data-newbie.tistory.com/252

 

[Python] confluent-Kafka 연습하기

## Producer 1 (topic odd) from confluent_kafka import Producer import numpy as np p = Producer({'bootstrap.servers': 'localhost'}) def delivery_report(err, msg): """ Called once for each message pro..

data-newbie.tistory.com

 

 

 

from confluent_kafka import Consumer, KafkaError

settings = {
    'bootstrap.servers': 'kafka:9092',
    'group.id': 'mygroup',
    'client.id': 'myclient',
    'enable.auto.commit': False,
    'session.timeout.ms': 6000,
    'default.topic.config': {'auto.offset.reset': 'earliest'}
}

c = Consumer(settings)

c.subscribe(['topic'])

try:
    while True:
        msg = c.poll(1)
        if msg is None:
            continue
        elif not msg.error():
            print('Received message: {0}:::{1}'.format(
                msg.offset(), msg.value()))
        elif msg.error().code() == KafkaError._PARTITION_EOF:
            print('End of partition reached {0}/{1}'
                  .format(msg.topic(), msg.partition()))
        else:
            print('Error occured: {0}'.format(msg.error().str()))

except KeyboardInterrupt:
    pass

finally:
    c.close()

 

'Python' 카테고리의 다른 글

Python Proxy  (0) 2021.11.03
Instaloader  (0) 2021.09.21
Ubuntu 20.04 / 18.04 / Debian 10에 Homebrew 설치  (0) 2021.09.11
Slack Bot  (0) 2021.08.15
pyenv  (0) 2021.08.04