Thoth

Thoth is a library that provides a way to implement event-sourcing in Java applications.

Event sourcing

Rather than maintaining an up-to-date application state, event sourcing focuses on what happened by storing events.

This approach provides by-design audit log for the application.

It is also very well suited for event-driven architectures : events can be published as is.

It plays well with CQRS : building and maintaining read projections is done by consuming events.

Thoth

Thoth guaranties that:

  • Events will be written in the database before being published in Kafka (to prevent failure)
  • Publication in Kafka will be reattempted until it succeeds

It provides capabilities of defining two types of projections :

  • “Real time” projections, that are updated in the same transaction as the events
  • “Eventually consistent” projections, updated asynchronously by consuming Kafka

Documentation

This documentation focuses on implementing event-sourcing on a simple use case : a banking application.

Installation

sbt
val ThothVersion = "1.1.4*"
libraryDependencies ++= Seq(
  "fr.maif" % "common-events" % ThothVersion,
  "fr.maif" %% "thoth-core" % ThothVersion,
  "fr.maif" %% "thoth-jooq" % ThothVersion,
  "fr.maif" %% "thoth-jooq-async" % ThothVersion,
  "fr.maif" %% "thoth-kafka-goodies" % ThothVersion
)
Maven
<properties>
  <thoth.version>1.1.4*</thoth.version>
</properties>
<dependency>
  <groupId>fr.maif</groupId>
  <artifactId>common-events</artifactId>
  <version>${thoth.version}</version>
</dependency>
<dependency>
  <groupId>fr.maif</groupId>
  <artifactId>thoth-core_2.12</artifactId>
  <version>${thoth.version}</version>
</dependency>
<dependency>
  <groupId>fr.maif</groupId>
  <artifactId>thoth-jooq_2.12</artifactId>
  <version>${thoth.version}</version>
</dependency>
<dependency>
  <groupId>fr.maif</groupId>
  <artifactId>thoth-jooq-async_2.12</artifactId>
  <version>${thoth.version}</version>
</dependency>
<dependency>
  <groupId>fr.maif</groupId>
  <artifactId>thoth-kafka-goodies_2.12</artifactId>
  <version>${thoth.version}</version>
</dependency>
Gradle
versions += [
  ThothVersion: "1.1.4*"
]
dependencies {
  compile group: 'fr.maif', name: 'common-events', version: versions.ThothVersion,
  compile group: 'fr.maif', name: 'thoth-core_2.12', version: versions.ThothVersion,
  compile group: 'fr.maif', name: 'thoth-jooq_2.12', version: versions.ThothVersion,
  compile group: 'fr.maif', name: 'thoth-jooq-async_2.12', version: versions.ThothVersion,
  compile group: 'fr.maif', name: 'thoth-kafka-goodies_2.12', version: versions.ThothVersion
}
The source code for this page can be found here.