Giter Club home page Giter Club logo

django-kafka's Introduction

Django Kafka ๐Ÿš

Django + Kafka + Celery ๐Ÿš€

Confluent Installation (Local set-up)

  • pip install confluent-kafka
  • Download confluent platform from: https://www.confluent.io/download/ and unzip the file.
  • export CONFLUENT_HOME=<path-to-confluent>
  • export PATH=$PATH:$CONFLUENT_HOME/bin
  • $CONFLUENT_HOME/bin/confluent-hub install \ --no-prompt confluentinc/kafka-connect-datagen:latest

The output would be:

Running in a "--no-prompt" mode
...
Completed
  • Start the service: confluent local start The output should resemble:
Starting Zookeeper
Zookeeper is [UP]
Starting Kafka
Kafka is [UP]
Starting Schema Registry
Schema Registry is [UP]
Starting Kafka REST
Kafka REST is [UP]
Starting Connect
Connect is [UP]
Starting KSQL Server
KSQL Server is [UP]
Starting Control Center
Control Center is [UP]
  • Stop services: confluent local stop

Or set-up Kafka and Zookeeper Separately

Kafka

  • Simply put, Kafka is a distributed publish-subscribe messaging system that maintains feeds of messages in partitioned and replicated topics.
  • In the simplest way there are three players in the Kafka ecosystem: producers, topics (run by brokers) and consumers.

Installation Zookeeper (MacOS)

  • brew install zookeeper
  • Where is installation directory of zookeeper : /usr/local/Cellar/zookeeper

Start Zookeeper

  • In foreground zkServer start
  • In background brew services start zookeeper

Installation Kafka (MacOS)

  • brew install kafka
  • Where is installation directory of Kafka : /usr/local/Cellar/kafka

Start Kafka

  • In foreground brew services start kafka
  • In background zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties & kafka-server-start /usr/local/etc/kafka/server.properties

For details on how to set-up a django project with best practices: https://pyblog.xyz/django-initial-setup/

Celery Installation - For polling

  • pip install amqp

  • pip install celery==4.4.0 (Note: Celery 5.0 is not compatible with django-celery-beat)

  • pip install django-celery-beat

  • Start worker and beat celery -A django_kafka beat -l INFO -S django

  • Start RabbitMQ brew services start rabbitmq

Update settings.py

INSTALLED_APPS = [
    ...,
    'django_celery_beat',
]
  • Run migrations: python manage.py migrate django_celery_beat

Note: In this project, the same Django project is the Producer and Consumer, but you can choose you have a standalone consumer.

Have a look at:

Note: The project is an example for Django application as a producer/consumer ๐Ÿ˜‹

django-kafka's People

Contributors

addu390 avatar

Stargazers

 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.