Giter VIP home page Giter VIP logo

learn-kafka-streams's Introduction

Learning Kafka Streams

Kafka Streams are a way to described/program operations on streams of data. It is a way to describe pipelines. It makes use of functional programming concepts.

Example1-MerginigStreams

In this example 2 streams are created and separate events are fed into each stream. A kafkastream 'merge' operation is used to combine both streams into a new combined stream.

stream started, as kafka consumer is ready.
stream started, as kafka consumer is ready.

Stream[stream1]	Payload	[stream1 0] //Stream 1 receives content written directly to stream 1
Stream[merge]	Payload	[stream1 0] //Merge stream receives content written originally to stream 1
Stream[stream2]	Payload	[stream2 0] //Stream 2 receives content written directly to stream 2
Stream[merge]	Payload	[stream2 0] //Merge stream receives content written originally to stream 2
Stream[stream1]	Payload	[stream1 1] //....and so on
Stream[merge]	Payload	[stream1 1]
Stream[stream2]	Payload	[stream2 1]
Stream[merge]	Payload	[stream2 1]
Stream[stream1]	Payload	[stream1 2]
Stream[merge]	Payload	[stream1 2]
Stream[stream2]	Payload	[stream2 2]
Stream[merge]	Payload	[stream2 2]
Stream[stream1]	Payload	[stream1 3]
Stream[merge]	Payload	[stream1 3]
Stream[stream2]	Payload	[stream2 3]
Stream[merge]	Payload	[stream2 3]

Example2-FilterStream

In this example one stream sees a set of payload which have incrementing value from 0 to 3. A filterstream is defined to only contain payloads which have event values.

const stream1 = kafkaStreams.getKStream("topic1");
let filteredstream = stream1.filter(x=>{
    return x.value%2===0
})

The log show exactly this behaviour

stream started, as kafka consumer is ready.
Stream[stream1]	Payload	[stream1 0]
Stream[filter]	Payload	[stream1 0] //Filter stream sees even value
Stream[stream1]	Payload	[stream1 1]
Stream[stream1]	Payload	[stream1 2]
Stream[filter]	Payload	[stream1 2] //Filter stream sees even value
Stream[stream1]	Payload	[stream1 3]

learn-kafka-streams's People

Contributors

bayeslife 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.