Code Monkey home page Code Monkey logo

spring-cloud-stream's Introduction

Spring Cloud Stream

What is Spring Cloud Stream

Spring Cloud Stream is a Spring module based of another module, Spring Cloud Function.
It allows creating event-driven applications by abstracting the binder type.

You can switch Kafka, RabbitMQ, AWS Kinesis and others, but you will not need to change anything in the code.

About the project

In this project I show you the Spring Cloud Stream with Kafka.
In the project there is an example of consumer and two examples of produces (both in imperative way and reactive way).
In the SensorEventFunctions class, I show you Spring Cloud Stream in reactive mode, in the SensorEventImperativeFunctions, I show you the same flow in the imperative mode.

Run the project

There is a docker-compose.yml file in the root of project to run Zookeeper and Kafka containers.
With Spring Boot 3.1, we have the docker compose support out of box (adding the spring-boot-docker-compose dependency). So, you can just run the application with your IDE or with command: ./mvnw spring-boot:run, and Spring will execute the docker compose in docker-compose.yml file and then the application.

There is an automatic producer that send the date every 5 seconds (the sensorEventAnotherProducer producer).

Profiles in the project

The project works both imperative and reactive mode, by the spring profiles (reactive and imperative).
The default mode is reactive, but you can replace the profile in application.yml.

DLQ and Retries

For the imperative mode, there is an automatic DQL and retry management of DLQ is provided by Spring.
The DLQ is handled by the enable-dlq and dlq-name properties. When the consumer throws an exception, the message will be processed again for two more times (the default of maxAttempts is 3), and after the message will be sent in DLQ.

For the reactive mode, you need to do a custom handling for DLQ and retries (see DlqEventUtil class).

References

spring-cloud-stream's People

Contributors

vincenzo-racca avatar vracca avatar vincenzo-racca-pa avatar

Stargazers

 avatar Kyriakos Mandalas avatar

Watchers

 avatar

Forkers

kmandalas

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.