GithubHelp home page GithubHelp logo

lombocska / spring-boot-outbox-transactional-sample Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 2.0 21 KB

Transactional outboxing w spring-integration-jdbc and postgres push notifications

Dockerfile 5.44% Java 90.76% Shell 1.21% PLpgSQL 2.59%
docker kafka messaging postgres-notifications postgresql spring-boot-3 spring-integration-jdbc

spring-boot-outbox-transactional-sample's Introduction

Spring-Boot 3.x integration with Postgres notify/listen mechanism

This example app is intended to be a showcase for integrating with Postgres as a message queue as well. Spring-Boot 3.x and Spring-Boot-Integration 6.x brought us the possibility to use postgres as a messaging queue withh Postgres LISTTEN/NOTIFY mechanism. With this new feature, we can implement outboxing pattern easily. :)

For the showcase there is a core-api and a listener service. (in docker-compose file, 2 listeners are configured) Core-API is eligible to save domains to the db and push notifications to the postgres "queues". Spring-integration-jdbc will create tables in postgres db with the prefix INT_, like INT_CHANNEL_MESSAGE, etc for handling the messaging in the background. In case of a successfully acked subscription on the consumer side, the message will be deleted from these utility tables. Listener service is there for subscribe and consume messages. If the consumption is not managed, the message won't be deleted from the tables.

With this setup outbox pattern at least once concept can be implemented for DB aand messaging broker transactions.

Usage

  • cd docker
  • Permission: chmod +x build.sh start.sh stop.sh
  • Build jar files: ./build.sh
  • Run Postgres, Kafka, Core-Api and 2 Listener services: ./start.sh
  • Requests againg Core-API: curl --location 'localhost:8081/api/cats' \ --header 'Content-Type: application/json' \ --data '{ "name": "Garfield", "age": 35 }'
  • curl --location 'localhost:8081/api/dogs' \ --header 'Content-Type: application/json' \ --data '{ "name": "Goofy", "age": 35 }''
  • At the end to stop containers: ./stop.sh

Tech Stack

  • Spring Boot (3.0.6) & Spring Boot Integration JDBC 6.0
  • Postgres 13.2
  • Spring Kafka
  • Docker Compose
  • Maven

Inspirations

spring-boot-outbox-transactional-sample's People

Contributors

lombocska avatar

Stargazers

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