Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


This project demonstrates how to implement an event-sourced web application based on the Eligosource Eventsourced library. It is based on former work that has been described in the articles

Compared to the old implementation, the whole service and persistence layer have been re-written and the domain events are now decoupled from the immutable domain model. The web UI and the web API remain unchanged.

The example web application uses the Eventsourced library for both event-sourcing and command-sourcing. Furthermore, it implements the CQRS pattern and follows domain-driven design principles.




  • The domain model is a rich, immutable domain model. It is annotated with JAXB annotations for XML and JSON binding.
  • The service layer implements the event-sourced and command-sourced actors (processors) together with service facades for asynchronous writes and synchronous, non-blocking reads of application state.
    • Processors manage application state via STM references.
    • For reading current state, services facades access STM references directly (concurrent reads).
    • For updating current state, services facades access STM references via processors where a single STM reference is updated by a single processor (single-writer-principle)
    • On the command-side of the implemented CQRS pattern is the InvoiceService that manages application state and serves consistent reads of invoices.
    • On the query side of the implemented CQRS pattern is the StatisticsService, a read model that serves eventually consistent reads about invoice update statistics.
    • The PaymentProcess is an example of a stateful, potentially long-running and event-sourced business process.
  • The web layer provides a RESTful service interface to application resources and supports HTML, XML and JSON representation formats. It is built on top of Jersey and Scalate. A Play-based version will follow (which supports asynchronous responses in contrast to Jersey).
  • The application configuration wires the pieces together.


Clone the example application and compile it

git clone git://
cd eventsourced-example
sbt compile


To start the example application, enter

> run-main org.eligosource.eventsourced.example.server.Webserver

at the sbt prompt. Then go to http://localhost:8080 and create some invoices.

The example application's RESTful service interface supports HTML, XML and JSON representation formats. Content negotiation is done via the Accept HTTP header. The following examples show how to get HTML and XML representations for invoice-3.


Click on http://localhost:8080/invoice/invoice-3. Provided you have created an invoice with id invoice-3 before, you should see something like



curl -H "Accept: application/xml" http://localhost:8080/invoice/invoice-3


<draft-invoice id="invoice-3" version="2">


A Scala web application demonstrating event-sourcing best practices




No packages published


You can’t perform that action at this time.