Skip to content

jango2015/confluent-kafka-python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Confluent's Apache Kafka client for Python

Confluent's Kafka client for Python wraps the librdkafka C library, providing full Kafka protocol support with great performance and reliability.

The Python bindings provides a high-level Producer and Consumer with support for the balanced consumer groups of Apache Kafka 0.9.

See the API documentation for more info.

License: Apache License v2.0

Usage

Producer:

from confluent_kafka import Producer

p = Producer({'bootstrap.servers': 'mybroker,mybroker2'})
for data in some_data_source:
    p.produce('mytopic', data.encode('utf-8'))
p.flush()

High-level Consumer:

from confluent_kafka import Consumer

c = Consumer({'bootstrap.servers': 'mybroker', 'group.id': 'mygroup',
              'default.topic.config': {'auto.offset.reset': 'smallest'}})
c.subscribe(['mytopic'])
while running:
    msg = c.poll()
    if not msg.error():
        print('Received message: %s' % msg.value().decode('utf-8'))
c.close()

See examples for more examples.

Prerequisites

Install

Install from PyPi:

$ pip install confluent-kafka

Install from source / tarball:

$ pip install .

Build

$ python setup.by build

If librdkafka is installed in a non-standard location provide the include and library directories with:

$ CPLUS_INCLUDE_PATH=/path/to/include LIBRARY_PATH=/path/to/lib python setup.py ...

Tests

Run unit-tests:

$ py.test

NOTE: Requires py.test, install by pip install pytest

Run integration tests:

$ examples/integration_test.py <kafka-broker>

WARNING: These tests require an active Kafka cluster and will make use of a topic named 'test'.

Generate documentation

Install sphinx and sphinx_rtd_theme packages and then:

$ make docs

or:

$ python setup.by build_sphinx

Documentation will be generated in docs/_build/.

About

Confluent's Apache Kafka Python client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 74.4%
  • Python 25.4%
  • Other 0.2%
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy