Giter Site home page Giter Site logo

maksrane100 / kafka_examples Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 55.64 MB

Demonstrates different Kafka examples such as i) Kafka Producer ii) Kafka Consumer iii) Kafka Streams iv) Kafka Streams Filtering & Conditional Redirection

Java 100.00%

kafka_examples's Introduction

// Demonstrates different Kafka examples such as i) Kafka Producer ii) Kafka Consumer iii) Kafka Streams iv) Kafka Streams Filtering & Conditional Redirection //

Assumptions:

These examples have been tested using kafka_2.13-2.5.0 and Java 8.

To run these examples,

i) zookeeper should be running:

C:\kafka\kafka_2.13-2.5.0\bin\windows>zookeeper-server-start.bat ....\config\zookeeper.properties [2020-05-27 20:25:40,094] INFO Reading configuration from: ....\config\zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig) [2020-05-27 20:25:40,098] WARN ....\config\zookeeper.properties is relative. Prepend .\ to indicate that you're sure! (org.apache.zookeeper.server.quorum.QuorumPeerConfig) [2020-05-27 20:25:40,111] WARN \tmp\zookeeper is relative. Prepend .\ to indicate that you're sure! (org.apache.zookeeper.server.quorum.QuorumPeerConfig) [2020-05-27 20:25:40,126] INFO clientPortAddress is 0.0.0.0:2181 (org.apache.zookeeper.server.quorum.QuorumPeerConfig)

ii) Kafka server should be running:

c:\kafka\kafka_2.13-2.5.0\bin\windows>kafka-server-start.bat ....\config\server.properties [2020-05-30 15:41:00,324] INFO Registered kafka:type=kafka.Log4jController MBean (kafka.utils.Log4jControllerRegistration$) [2020-05-30 15:41:02,149] INFO Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation (org.apache.zookeeper.common.X509Util) [2020-05-30 15:41:02,534] INFO starting (kafka.server.KafkaServer) [2020-05-30 15:41:02,536] INFO Connecting to zookeeper on localhost:2181 (kafka.server.KafkaServer) [2020-05-30 15:41:02,630] INFO [ZooKeeperClient Kafka server] Initializing a new session to localhost:2181. (kafka.zookeeper.ZooKeeperClient)

iii) Kafka topics that the examples use should be created. A sample topic can be created as follows:

c:\kafka\kafka_2.13-2.5.0\bin\windows>kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic PersonOutputUSAUsersTopic Created topic PersonOutputUSAUsersTopic.

c:\kafka\kafka_2.13-2.5.0\bin\windows>

iv) Kafka consumer can be run from command prompt like this:

c:\kafka\kafka_2.13-2.5.0\bin\windows>kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic PersonOutputIndiaUsersTopic 0,GEETA A. PATIL,INDIA,SOFTWARE ANALYST [SAT MAY 30 13:03:11 PDT 2020] 2,GEETA A. PATIL,INDIA,SOFTWARE ANALYST [SAT MAY 30 13:03:12 PDT 2020] 0,AMIT A. PATIL,INDIA,SOFTWARE ANALYST [SAT MAY 30 13:11:15 PDT 2020] 2,AMIT A. PATIL,INDIA,SOFTWARE ANALYST [SAT MAY 30 13:11:16 PDT 2020]

c:\kafka\kafka_2.13-2.5.0\bin\windows>kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic PersonOutputUSAUsersTopic

Topics "PersonOutputIndiaUsersTopic" and "PersonOutputUSAUsersTopic" have be used in the examples to demonstrate how we can do kafka streams condition based filtering and redirection to different topics.

#################### To Run Orders Example, Create Following Topics ####################

c:\kafka\kafka_2.13-2.5.0\bin\windows>kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic OrderDetailsTopic1 Created topic OrderDetailsTopic1.

c:\kafka\kafka_2.13-2.5.0\bin\windows>kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic IndiaOrdersOutputTopic Created topic IndiaOrdersOutputTopic.

c:\kafka\kafka_2.13-2.5.0\bin\windows>kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic USAOrdersOutputTopic Created topic USAOrdersOutputTopic.

kafka_examples's People

Contributors

maksrane100 avatar

Watchers

James Cloos avatar  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.