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 = "0.1.0*"
libraryDependencies ++= Seq(
"fr.maif" % "commons-events" % ThothVersion,
"fr.maif" % "thoth-core-akka" % ThothVersion,
"fr.maif" % "thoth-core-reactor" % ThothVersion,
"fr.maif" % "thoth-jooq" % ThothVersion,
"fr.maif" % "thoth-jooq-akka" % ThothVersion,
"fr.maif" % "thoth-kafka-consumer-akka" % ThothVersion,
"fr.maif" % "thoth-kafka-consumer-reactor" % ThothVersion
)
- Maven
<properties>
<thoth.version>0.1.0*</thoth.version>
</properties>
<dependencies>
<dependency>
<groupId>fr.maif</groupId>
<artifactId>commons-events</artifactId>
<version>${thoth.version}</version>
</dependency>
<dependency>
<groupId>fr.maif</groupId>
<artifactId>thoth-core-akka</artifactId>
<version>${thoth.version}</version>
</dependency>
<dependency>
<groupId>fr.maif</groupId>
<artifactId>thoth-core-reactor</artifactId>
<version>${thoth.version}</version>
</dependency>
<dependency>
<groupId>fr.maif</groupId>
<artifactId>thoth-jooq</artifactId>
<version>${thoth.version}</version>
</dependency>
<dependency>
<groupId>fr.maif</groupId>
<artifactId>thoth-jooq-akka</artifactId>
<version>${thoth.version}</version>
</dependency>
<dependency>
<groupId>fr.maif</groupId>
<artifactId>thoth-kafka-consumer-akka</artifactId>
<version>${thoth.version}</version>
</dependency>
<dependency>
<groupId>fr.maif</groupId>
<artifactId>thoth-kafka-consumer-reactor</artifactId>
<version>${thoth.version}</version>
</dependency>
</dependencies>
- Gradle
def versions = [
ThothVersion: "0.1.0*"
]
dependencies {
implementation "fr.maif:commons-events:${versions.ThothVersion}"
implementation "fr.maif:thoth-core-akka:${versions.ThothVersion}"
implementation "fr.maif:thoth-core-reactor:${versions.ThothVersion}"
implementation "fr.maif:thoth-jooq:${versions.ThothVersion}"
implementation "fr.maif:thoth-jooq-akka:${versions.ThothVersion}"
implementation "fr.maif:thoth-kafka-consumer-akka:${versions.ThothVersion}"
implementation "fr.maif:thoth-kafka-consumer-reactor:${versions.ThothVersion}"
}