Coder Social home page Coder Social logo

deploy_kafka_docker's Introduction

deploy_kafka_docker

Deploy Kafka on Docker. Play with it using Python

Start the docker-compose with console log output

docker-compose up

Run it in detach mode

docker-compose up -d

Stop Everything

docker-compose down

Python

Create a virtualenv and install the requirements file

pip install -r requirements.txt

Run consumer

python consumer.py

Run producer

python producer.py

Producer Sample Output

{'test_data': {'random_value': 7}, 'timestamp': '2022-09-24 17:49:15.064358', 'value_status': 'High'}
{'test_data': {'random_value': 5}, 'timestamp': '2022-09-24 17:49:18.091630', 'value_status': 'Low'}
{'test_data': {'random_value': 4}, 'timestamp': '2022-09-24 17:49:21.109652', 'value_status': 'Low'}
{'test_data': {'random_value': 7}, 'timestamp': '2022-09-24 17:49:24.129282', 'value_status': 'High'}
{'test_data': {'random_value': 7}, 'timestamp': '2022-09-24 17:49:27.153339', 'value_status': 'High'}
{'test_data': {'random_value': 4}, 'timestamp': '2022-09-24 17:49:30.177412', 'value_status': 'Low'}
{'test_data': {'random_value': 7}, 'timestamp': '2022-09-24 17:49:33.214183', 'value_status': 'High'}
{'test_data': {'random_value': 4}, 'timestamp': '2022-09-24 17:49:36.244142', 'value_status': 'Low'}

Consumer Sample Output

ConsumerRecord(topic='test_topic', partition=0, offset=16, timestamp=1664034555065, timestamp_type=0, key=None, value={'test_data': {'random_value': 7}, 'timestamp': '2022-09-24 17:49:15.064358', 'value_status': 'High'}, headers=[], checksum=None, serialized_key_size=-1, serialized_value_size=101, serialized_header_size=-1)
{'test_data': {'random_value': 7}, 'timestamp': '2022-09-24 17:49:15.064358', 'value_status': 'High'}
ConsumerRecord(topic='test_topic', partition=0, offset=17, timestamp=1664034558091, timestamp_type=0, key=None, value={'test_data': {'random_value': 5}, 'timestamp': '2022-09-24 17:49:18.091630', 'value_status': 'Low'}, headers=[], checksum=None, serialized_key_size=-1, serialized_value_size=100, serialized_header_size=-1)
{'test_data': {'random_value': 5}, 'timestamp': '2022-09-24 17:49:18.091630', 'value_status': 'Low'}
ConsumerRecord(topic='test_topic', partition=0, offset=18, timestamp=1664034561109, timestamp_type=0, key=None, value={'test_data': {'random_value': 4}, 'timestamp': '2022-09-24 17:49:21.109652', 'value_status': 'Low'}, headers=[], checksum=None, serialized_key_size=-1, serialized_value_size=100, serialized_header_size=-1)
{'test_data': {'random_value': 4}, 'timestamp': '2022-09-24 17:49:21.109652', 'value_status': 'Low'}
ConsumerRecord(topic='test_topic', partition=0, offset=19, timestamp=1664034564130, timestamp_type=0, key=None, value={'test_data': {'random_value': 7}, 'timestamp': '2022-09-24 17:49:24.129282', 'value_status': 'High'}, headers=[], checksum=None, serialized_key_size=-1, serialized_value_size=101, serialized_header_size=-1)
{'test_data': {'random_value': 7}, 'timestamp': '2022-09-24 17:49:24.129282', 'value_status': 'High'}
ConsumerRecord(topic='test_topic', partition=0, offset=20, timestamp=1664034567153, timestamp_type=0, key=None, value={'test_data': {'random_value': 7}, 'timestamp': '2022-09-24 17:49:27.153339', 'value_status': 'High'}, headers=[], checksum=None, serialized_key_size=-1, serialized_value_size=101, serialized_header_size=-1)
{'test_data': {'random_value': 7}, 'timestamp': '2022-09-24 17:49:27.153339', 'value_status': 'High'}
ConsumerRecord(topic='test_topic', partition=0, offset=21, timestamp=1664034570178, timestamp_type=0, key=None, value={'test_data': {'random_value': 4}, 'timestamp': '2022-09-24 17:49:30.177412', 'value_status': 'Low'}, headers=[], checksum=None, serialized_key_size=-1, serialized_value_size=100, serialized_header_size=-1)
{'test_data': {'random_value': 4}, 'timestamp': '2022-09-24 17:49:30.177412', 'value_status': 'Low'}

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.