Microservices with Spring Boot and Kafka Demo Project

Overview

Microservices with Spring Boot and Kafka Demo Project Twitter

Articles

This repository is used as the example for the following articles:

  1. Distributed Transactions in Microservices with Kafka Streams and Spring Boot - how to implement distributed transaction based on the SAGA pattern with Spring Boot and Kafka Streams
  2. Deep Dive into Saga Transactions with Kafka Streams and Spring Boot - how to implement distributed transaction based on the SAGA pattern with Spring Boot and fully Kafka Streams KStream and KTable. You need to switch to the streams-full branch.

Description

There are three microservices:
order-service - it sends Order events to the Kafka topic and orchestrates the process of a distributed transaction
payment-service - it performs local transaction on the customer account basing on the Order price
stock-service - it performs local transaction on the store basing on number of products in the Order

Here's the diagram with our architecture:

image

(1) order-service send a new Order -> status == NEW
(2) payment-service and stock-service receive Order and handle it by performing a local transaction on the data
(3) payment-service and stock-service send a reponse Order -> status == ACCEPT or status == REJECT
(4) order-service process incoming stream of orders from payment-service and stock-service, join them by Order id and sends Order with a new status -> status == CONFIRMATION or status == ROLLBACK or status == REJECTED
(5) payment-service and stock-service receive Order with a final status and "commit" or "rollback" a local transaction make before

You might also like...

Spring Boot ECommerce Demo

Spring Boot ECommerce Demo

springboot-ecommerce2 Things todo list Clone this repository: git clone https://github.com/hendisantika/springboot-ecommerce2.git Navigate to the fold

Aug 30, 2022

Spring Boot Debezium Kafka PostgreSQL Relationship

Spring Boot Debezium Kafka PostgreSQL Relationship

spring-boot-debezium-db-kafka Spring-Boot-Debezium-Kafka-PostgreSQL Relationship Installation First,Configure docker-compose.yml Second,Write Db-Kafka

Aug 26, 2022

Kafka integration with Java Spring-boot: producer-consumer model

Kafka integration with Java Spring-boot with one application serving as a producer and the other consuming the messages

Apr 26, 2022

Source code of Spring boot + Apache Kafka Udemy Course

Spring Boot + Apache Kafka - The Quickstart Practical Guide- Udemy course Course link: https://www.udemy.com/course/spring-boot-and-apache-kafka/?refe

Dec 21, 2022

Spring for GraphQL demo project with a Vue frontend.

Spring Books - Hello GraphQL This is a demo project that will introduce you to [https://spring.io/projects/spring-graphql](Spring for GraphQL). The Sp

Dec 2, 2022

A high availability shopping(ecommerce) system using SpringBoot, Spring Cloud, Eureka Server, Spring Cloud Gateway, resillience4j, Kafka, Redis and MySQL.

A high availability shopping(ecommerce) system using SpringBoot, Spring Cloud, Eureka Server, Spring Cloud Gateway, resillience4j, Kafka, Redis and MySQL.

High-availability-shopping-system A high availability shopping(ecommerce) system using SpringBoot, Spring Cloud, Eureka Server, Spring Cloud Gateway,

Oct 26, 2022

Two Spring-boot applications registering themselves to an spring-boot-admin-server application as separate clients for the purpose of monitoring and managing the clients

Two Spring-boot applications registering themselves to an spring-boot-admin-server application as separate clients for the purpose of monitoring and managing the clients

Spring-boot-admin implementation with 1 Server and 2 clients Creating a Server application to monitor and manage Spring boot applications (clients) un

Dec 6, 2022

The Spring Boot Sample App on K8S has been implemented using GKE K8S Cluster, Spring Boot, Maven, and Docker.

gke-springboot-sampleapp 👋 The Spring Boot Sample App on K8S has been implemented using GKE K8S Cluster, Spring Boot, Maven, and Docker. Usage To be

Feb 1, 2022

Codebase for talk on Spring I/O 2022 in Barcelona about Spring for Apache Kafka

Codebase for talk on Spring I/O 2022 in Barcelona about Spring for Apache Kafka

Spring I/O Barcelona 2022 - Spring Kafka beyond the basics Codebase for my talk on Spring I/O 2022 in Barcelona about Spring for Apache Kafka Slides P

Dec 24, 2022
Comments
  • Random.nextLong(long bound)

    Random.nextLong(long bound)

    https://github.com/piomin/sample-spring-kafka-microservices/blob/4082c112988bdda02d880075f81100d457c68eae/order-service/src/main/java/pl/piomin/order/service/OrderGeneratorService.java#L29

    There is no method nextLong available which takes an upper bound.

    opened by mehdi-reza 2
  • payment-service returns wrong status if reserve fails

    payment-service returns wrong status if reserve fails

    https://github.com/piomin/sample-spring-kafka-microservices/blob/4082c112988bdda02d880075f81100d457c68eae/payment-service/src/main/java/pl/piomin/payment/service/OrderManageService.java#L32

    As the documentation it should return "REJECT" instead of "REJECTED". With "REJECTED" status at the streams join the Order status property will be evaluate to null and the listeners will got NullPointerExceptions.

    opened by gergolep 1
  • Add License

    Add License

    You have done cool work.

    I would like to fork your project and use that for my learning and enhance it, but I cannot use due to missing license. I will provide credits to your blogpost.

    Github says missing license does not allow me to use your code as a base.

    If you willing to let me use the code, add license using this guide. I'd do it for you, but I have no clue what type of license you would like to have. :)

    Thank you!

    opened by rajadilipkolli 0
Owner
Piotr Mińkowski
Software Architect and Java Developer
Piotr Mińkowski
Kafka-spring-boot-starter: encapsulated based on spring-kafka

Encapsulation based on spring-kafka not only supports native configuration, but also adds multi data source configuration.

liudong 8 Jan 9, 2023
循序渐进,学习Spring Boot、Spring Boot & Shiro、Spring Batch、Spring Cloud、Spring Cloud Alibaba、Spring Security & Spring Security OAuth2,博客Spring系列源码:https://mrbird.cc

Spring 系列教程 该仓库为个人博客https://mrbird.cc中Spring系列源码,包含Spring Boot、Spring Boot & Shiro、Spring Cloud,Spring Boot & Spring Security & Spring Security OAuth2

mrbird 24.8k Jan 6, 2023
End to End project for Kafka Streams using Spring Cloud Kafka streams

Spring Kafka Streams using Spring Cloud Streams End to End example Endpoint http://localhost:8080/domain/lookup/facebook - to pull all facebook relate

TechPrimers 43 Dec 20, 2022
Example project of Spring Boot Microservices with the following services School and Student

SpringBootMicroservicesWithDiscoveryGatewayConfig Example project of Spring Boot Microservices with the following services School and Student, additio

Gábor Hutya 2 Nov 28, 2022
Spring Boot microservices app with Spring Cloud, Robust and resilient backend managing e-Commerce app

e-Commerce-boot μServices Important Note: This project's new milestone is to move The whole system to work on Kubernetes, so stay tuned. Introduction

Selim Horri 65 Dec 23, 2022
Demo microservice architecture with Spring ,Spring Cloud Gateway , Spring Cloud config server , Eureuka , keycloak and Docker.

spring-microservice Demo microservice architecture with Spring ,Spring Cloud Gateway , Spring Cloud config server , Eureuka , keycloak and Docker. Arc

null 4 Sep 13, 2022
Spring Boot Login and Registration example with MySQL, JWT, Rest Api - Spring Boot Spring Security Login example

Spring Boot Login example with Spring Security, MySQL and JWT Appropriate Flow for User Login and Registration with JWT Spring Boot Rest Api Architect

null 58 Jan 5, 2023
Spring-boot application to demo JVM HEAP and Native memory leak

Description This repo can be used as demo repo for finding memory leaks. Example spring-boot project to show how to find and fix JVM HEAP memory leak

Iranna Nk 4 Jul 22, 2022
A Spring Boot Camel boilerplate that aims to consume events from Apache Kafka, process it and send to a PostgreSQL database.

SPRING-BOOT CAMEL BOILERPLATE This is a Spring-Boot Camel Application model that you can use as a reference to study or even to use in your company. I

Bruno Delgado 45 Apr 4, 2022
LOQUI - Real-time chat application built using Apache Kafka, Java, Spring Boot, SockJS and React

LOQUI is a simple real-time chat application that demonstrates how to use Apache Kafka as a message broker along with Java, Spring Boot and React on the front-end

Castanho Correia 2 Jun 5, 2022