Code Monkey home page Code Monkey logo

django-kafka-consumer's Introduction

Django Kafka Consumer

Purpose

Django Kafka Consumer is an utility for consume events from Kafka

Quick start

  1. Add kafka_consumer to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        # ...
        'kafka_consumer',
    ]
    
  2. Run python manage.py migrate to create the kafka_consumer models.

  3. Add custom subscribers as classes derived from kafka_consumer.subscribers.base.BaseSubscriber

  4. Prepare settings:

    KAFKA_HOSTS = ['kafka-host.com:9092']
    
    KAFKA_CONSUMER_TOPICS = {
        'topic_key': {
            'topic': 'topic name',  # no spaces allowed!
            'group': 'topic group',
            'client': 'client ID',
            'subscribers': (
                'path.to.subscriber.Class',
            ),
            'message_processor': 'processor key',  # lookup in KAFKA_CONSUMERS_MESSAGE_PROCESSORS
            'wait': 0,  # optional, indicates how many seconds Kafka will wait to fillup buffer, None or ommited means wait forever
            'max_number_of_messages_in_batch': 200,
            'consumer_options': {  # Overrides options used to create KafkaConsumer
                'auto_offset_reset': 'latest',
            }
        },
    }
    KAFKA_CONSUMERS_MESSAGE_PROCESSORS = {
      'processor key': {
        'class': 'path.to.messageprocessor.Class',
        # Processors init arguments, e.g.
        'rsa_private_key_path': 'path/to/private/key'
      },
    }
    
    KAFKA_CONSUMER_SSL_SETTINGS = {
        'security_protocol': 'SSL',
        'ssl_cafile': '/path/to/file/ca.crt',
        'ssl_certfile': '/path/to/file/signed.request.crt',
        'ssl_keyfile': '/path/to/some/keyfile.key',
    }
    
  5. To continuously consume events from kafka run:

    python manage.py consume --supervised --topic topic_key
    

License

The Django Kafka Consumer package is licensed under the FreeBSD License.

django-kafka-consumer's People

Contributors

githubiiit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.