Coder Social home page Coder Social logo

grussell-spring-kafka's Introduction

grussell-spring-kafka

Spring for Apache Kafka @SpringOnePlatform

Projects

s1p-kafka

This project is used for the demos; it has a number of Spring Boot applications, demonstrating various capabilities of spring-kafka.

Each application is in package org.s1p.appX (where appX is app1, app2, etc).

Common configuration is in the CommonConfiguration class.

The apps require 2 topics to be created in Kafka...

kafka-topics --zookeeper localhost:2181 --create --topic s1p.topic --partitions 5 --replication-factor 1

kafka-topics --zookeeper localhost:2181 --create --topic s1p.fooTopic --partitions 5 --replication-factor 1

The first four apps use String serializers and deserializers for both the key and value.

app1

This is the first app which simply sends a message to the s1p.topic.

app2

This adds a simple @KafkaListener to receive messages from s1p.topic in a POJO method.

app3

This shows how to access the partition from which the message was received in a @KafkaListener POJO method.

app4

This shows a @KafkaListener where the topics/partitions are explicitly subscribed to, together with an initial offset.

app5

This introduces JSON serializer and deserializer for the value. It uses JsonConfiguration instead of CommonConfiguration; note that the type (Foo) is hard-coded into the deserializer - this is required since the JSON contains no type information.

app6

This is a more flexible alternative to using the Json serializer and deserializer. Instead, it uses StringJsonMessageConverter s and reverts to using String serializer/deserializer. One benefit of this technique is the type used in the conversion is inferred from the method argument type. Notice that we send a Foo and receive a Bar - of course, the types need to have compatible fields.

app7

This builds on app2 by adding retry and filtering to the listener.

app8

This version of app2 uses the lower-level KafkaMessageListenerContainer instead of a @KafkaListener.

app9

This version of app8 commits the offsets manually.

grussell-spring-kafka's People

Contributors

garyrussell avatar

Watchers

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