Giter Club home page Giter Club logo

ds_kafka-for-developers-using-schema-registry's Introduction

Kafka For Developers - Data Contracts using Schema Registry

This repository has the content to interact with Kafka using AVRO and Schema Registry.

Set up Kafka Environment using Docker

  • This should set up the Zookeeper and Kafka Broker in your local environment
docker-compose up

Verify the Local Kafka Environment

  • Run this below command
docker ps
  • You should be below containers up and running in local
CONTAINER ID   IMAGE                                   COMMAND                  CREATED          STATUS          PORTS                                            NAMES
fd305f78339a   confluentinc/cp-schema-registry:7.1.0   "/etc/confluent/dock…"   49 seconds ago   Up 48 seconds   0.0.0.0:8081->8081/tcp                           schema-registry
fb28f7f91b0e   confluentinc/cp-server:7.1.0            "/etc/confluent/dock…"   50 seconds ago   Up 49 seconds   0.0.0.0:9092->9092/tcp, 0.0.0.0:9101->9101/tcp   broker
d00a0f845a45   confluentinc/cp-zookeeper:7.1.0         "/etc/confluent/dock…"   50 seconds ago   Up 49 seconds   2888/tcp, 0.0.0.0:2181->2181/tcp, 3888/tcp       zookeeper

Interacting with Kafka

Produce Messages

  • This command should take care of logging in to the Kafka container.
docker exec -it broker bash
  • Command to produce messages in to the Kafka topic.
kafka-console-producer --broker-list localhost:9092 --topic test-topic

Consume Messages

  • This command should take care of logging in to the Kafka container.
docker exec -it broker bash
  • Command to produce messages in to the Kafka topic.
kafka-console-consumer --bootstrap-server localhost:9092 --topic test-topic

Interacting with Kafka using AVRO Records

Produce AVRO Messages

  • This command should take care of logging in to the Schema Registry container.
docker exec -it schema-registry bash
  • Run the kafka-avro-console-producer with the Schema
kafka-avro-console-producer --broker-list broker:29092 --topic greetings --property value.schema='{"type": "record","name":"Greeting","fields": [{"name": "greeting","type": "string"}]}'
  • Publish the Greeting message
{"greeting": "Good Morning!, AVRO"}
{"greeting": "Good Evening!, AVRO"}
{"greeting": "Good Night!, AVRO"}

Consume AVRO Messages

  • This command should take care of logging in to the Schema Registry container.
docker exec -it schema-registry bash

  • Run the kafka-avro-console-consumer
kafka-avro-console-consumer --bootstrap-server broker:29092 --topic greetings --from-beginning

Kafka Helpful Commands

  • To view the list of topics in the Kafka environment.
kafka-topics --bootstrap-server localhost:9092 --describe
  • Note : Schemas are stored in an internal topic named _schemas*

  • Lets view the configuration set up for _schemas topics

kafka-topics --bootstrap-server localhost:9092 --describe --topic _schemas

ds_kafka-for-developers-using-schema-registry's People

Contributors

dilipsundarraj avatar dilipsundarraj1 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.