Coder Social home page Coder Social logo

naveenbavu / kafka-streams-spring-boot-json-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mknutty/kafka-streams-spring-boot-json-example

0.0 1.0 0.0 56 KB

Spring Boot example of how to read in JSON from a Kakfa topic and, via Kafka Streams, create a single json doc from subsequent JSON documents.

Shell 41.04% Batchfile 31.69% Java 27.27%

kafka-streams-spring-boot-json-example's Introduction

kafka-streams-spring-boot-json-example

This is a Spring Boot example of how to read in JSON from a Kakfa topic and, via Kafka Streams, create a single json doc from subsequent JSON documents.

The reason I created this is because I need to combine multiple JSON different documents into a single JSON document and I could not find a good example for all of the parts. There will be an upstream process to convert the different documents into a single format. A process will listen to the output topic and as changes are emitted, it query the state store to ensure it has the latest in case there are multiple consumers and insert it into full-text index.

To run this locally,

  1. Get Kafka and run it. Follow the directions (if you are running on Windows) in the following link (except get kafka_2.11-1.0.0) - https://stackoverflow.com/questions/23115013/is-there-an-easy-way-to-install-kafka-on-windows/44514537#44514537. If you are running Linux or OSX, instructions are here - https://kafka.apache.org/quickstart .

  2. Create the 3 topics in the KafkaStreamsDefaultConfiguration class. Instructions are here - https://kafka.apache.org/quickstart#quickstart_createtopic .

  3. Start the Spring Boot app. I like doing it from STS.

  4. Start the consumer connecting to the output topic. Instructions for running it are here - https://kafka.apache.org/quickstart#quickstart_consume .

  5. Run the producer connecting to the input topic and send JSON messages.

    1. Instructions are here - https://kafka.apache.org/quickstart#quickstart_send
    2. The JSON format is like this - {"key":"somekey","words":["word1"]}
    3. Send subsequent JSON documents changing the "words". e.g. {"key":"somekey","words":["word2"]}.

If you forget to create the topics first, weird things will happen (i.e. messages might not seem to process till you send another or restart the app). If things get screwed up, stop all the processes (Consumer, App, Producer, Kafka, Zookeeper), delete things in /logs and /tmp and redo 1-5 (sans the install parts - Run Zookeeper, Kafka. Create topics. Run App, Consumer, Producer. Send JSON).

kafka-streams-spring-boot-json-example's People

Contributors

mknutty avatar

Watchers

 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.