Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Proposal solution for the Dual Write problem

NotificationsYou must be signed in to change notification settings

asterixcode/spring-outbox-pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Description

How to solve theDual Write problem using theOutbox Pattern with a pull and publish scheduler.

Dual Write problem

This project is a simple solution for theDual Write problem.

TheDual Write problem happens when:

  • the application needs to write to two different systems in a single transaction
  • the systems have different transactional boundaries
  • if one of the writes fails, the other write can't be rolled back, leaving the system in an inconsistent state

Example:

Write to a database and to a message broker.

TheDual Write problem can be solved using theOutbox Pattern, which makes sure that if one of the writes fails, the system can still recover the state inside the transaction and roll back all the writes.

Outbox Pattern implementation

There are probably different ways to implement theOutbox Pattern, but this simple project implements it using:

  • a database table calledoutbox that contains all the messages that need to be sent to the message broker
  • a scheduled task that reads the messages from theoutbox table and sends them to the message broker

Then, once a service needs to write to theorders table, for example, it also writes to theoutbox table in the same transaction.

Technologies used

  • Java 21
  • Spring Boot 3.3.2
  • Spring Data JDBC
  • PostgreSQL
  • Docker Compose
  • Kafka

About

Proposal solution for the Dual Write problem

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp