<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>The blog of Alexander Langer</title>
 <link href="http://blog.langer.eu/atom.xml" rel="self"/>
 <link href="http://blog.langer.eu"/>
 <updated>2015-07-15T14:57:36+00:00</updated>
 <id>http://blog.langer.eu</id>
 <author>
   <name>Alexander Langer</name>
   <email>alex@big.endian.de</email>
 </author>

 
 <entry>
   <title>JEEventStore - Design Rationale and Feature Wishlist</title>
   <link href="http://blog.langer.eu/2015/07/15/java-event-store-design.html"/>
   <updated>2015-07-15T00:00:00+00:00</updated>
   <id>http://blog.langer.eu/2015/07/15/java-event-store-design</id>
   <content type="html">&lt;p&gt;Since no existing event store for Java &lt;a href=&quot;/2014/09/02/event-store-for-java.html&quot;&gt;fits our needs&lt;/a&gt; and integrates well with Java EE, I decided to write our own implementation of an event store, which is straight-forward anyways. &lt;/p&gt;

&lt;p&gt;As for the architecture of an event store, Jonathan Oliver’s &lt;a href=&quot;https://github.com/NEventStore/NEventStore&quot;&gt;NEventStore&lt;/a&gt; is extremely well designed.   In principle, it is exactly what we were looking for — except that it is written in C#/.NET and not Java.  NEventStore nevertheless served as an architectural template for our own Java event store, which you’ll surely notice when looking at the public API, see e.g. &lt;a href=&quot;https://github.com/NEventStore/NEventStore/blob/master/src/NEventStore/IStoreEvents.cs&quot;&gt;IStoreEvents.cs&lt;/a&gt; and &lt;a href=&quot;https://github.com/JEEventStore/JEEventStore/blob/master/core/src/main/java/org/jeeventstore/EventStore.java&quot;&gt;EventStore.java&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;At the same time, I did not want to reinvent the wheel.  In particular, although NEventStore advertises itself as a &lt;em&gt;persistence agnostic Event Store for .NET&lt;/em&gt;, there already is a persistence API that is agnostic to the underlying database in Java EE — JPA.  While JPA might mean some performance overhead, it is the standard persistence technology provided by Java EE and therefore widely supported on the containers and databases.  Additionally, authentication to the database server and other infrastructure concerns such as connection pooling can be configured directly in the container.  &lt;/p&gt;

&lt;p&gt;Another (minor) problem regards asynchronicity in the Java EE context:  Java EE applications &lt;a href=&quot;http://stackoverflow.com/questions/533783/why-spawning-threads-in-java-ee-container-is-discouraged&quot;&gt;must not&lt;/a&gt; create or fiddle with their own threads as these interfere with the container’s resources.  Anything that shall be run asynchronous must therefore be done with provided Java EE APIs.
On the positive side, the container guarantees thread-safety of EJBs and automatically manages a pool of stateless beans, which can be configured by the server operator.  In particular, when running multiple nodes in a cluster, the container can automatically route incoming requests between cluster nodes, i.e., we get horizontal scaling almost for free.&lt;/p&gt;

&lt;p&gt;Finally, I wanted to keep the event store modular, such that one can easily exchange, say, the underlying persistence layer (e.g., from JPA to JDBC or some NoSQL store), change the serialization format or add caching layers.  Implemented properly, the injection of resources and other EJB beans into the services can be configured by the developers or the server operators as needed.  This opens the door for extreme modularity.  For example, suppose the team would like to add a caching layer to the serialization engine, since they found that too much time is spent in this part of the application.  Easy – simply add a caching decorator of the serialization engine and inject this decorator into the event store.&lt;/p&gt;

&lt;h1 id=&quot;feature-list&quot;&gt;Feature List&lt;/h1&gt;

&lt;p&gt;This brings us to the feature wish list I had in mind when designing JEEventStore:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Target platform: Java EE.&lt;/li&gt;
  &lt;li&gt;No additional dependencies except, of course, for the serialization library of choice and/or the persistence engine.&lt;/li&gt;
  &lt;li&gt;Events shall not be needed to implement an interface provided by the event store to be stored.&lt;/li&gt;
  &lt;li&gt;Support multiple buckets in the event store (e.g., for multitenancy or multiple bounded context)&lt;/li&gt;
  &lt;li&gt;Be able to query all events of a bucket or all events of a given event stream; order guarantee per stream&lt;/li&gt;
  &lt;li&gt;Be able to query all events in a given event stream &lt;/li&gt;
  &lt;li&gt;Query specific versions of an event stream&lt;/li&gt;
  &lt;li&gt;Append-only mode:  Store events without requiring to read the object from database (saves a database roundtrip)&lt;/li&gt;
  &lt;li&gt;Event streams support change sets of multiple events with transaction semantics:  either store all events in a change set or none; each committed change set bumps the stream version by one&lt;/li&gt;
  &lt;li&gt;Optimistic Locking &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Modularity&lt;/strong&gt;, i.e., all infrastructure details can be replaced transparent to the clients; support different serialization and persistence engines, to be configured in the deployment descriptor&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;modularity&quot;&gt;Modularity&lt;/h1&gt;

&lt;p&gt;Some of the modularity features I had in mind:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Cache reads from the persistence layer by adding a decorator to the actual persistence engine&lt;/li&gt;
  &lt;li&gt;Cache de-serialization of events by adding a decorator to the serialization engine&lt;/li&gt;
  &lt;li&gt;Add encryption by adding a suitable decorator to the serialization engine&lt;/li&gt;
  &lt;li&gt;Add other persistence engines beside JPA, e.g., direct JDBC access, MongoDB or other NoSQL engines with suitable atomicity semantics (Redis might be a candidate)&lt;/li&gt;
  &lt;li&gt;Add other serialization engines beside GSON, e.g., XML, Protobuff, …&lt;/li&gt;
  &lt;li&gt;All event updasting by writing custom type converters&lt;/li&gt;
  &lt;li&gt;Ease of use:  provide drop-in EJB-jars, which developers can simply include in the Maven configuration to add JEEventStore to their application&lt;/li&gt;
  &lt;li&gt;be able to write own deployment descriptors for more complex setups with multiple decorators&lt;/li&gt;
  &lt;li&gt;An &lt;strong&gt;event notification&lt;/strong&gt; system to let listeners know about newly committed events (required for CQRS), which runs within the same transaction, to avoid polling of the database.  Support polling for persistence layers without transaction semends or when 2-Phase-Commits with the messaging infrastructure shall be avoided.&lt;/li&gt;
&lt;/ul&gt;

</content>
 </entry>
 
 <entry>
   <title>Literature on Event Sourcing, Event Stores and CQRS</title>
   <link href="http://blog.langer.eu/2014/09/02/literature.html"/>
   <updated>2014-09-02T00:00:00+00:00</updated>
   <id>http://blog.langer.eu/2014/09/02/literature</id>
   <content type="html">&lt;p&gt;A collection of literature I recommend for reading on Event Sourcing/Event Stores and CQRS, to be extended over time.  Ranges from high-level beginner material to implementation details and code samples.&lt;/p&gt;

&lt;h1 id=&quot;event-sourcing&quot;&gt;Event Sourcing&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://martinfowler.com/eaaDev/EventSourcing.html&quot;&gt;Event Sourcing&lt;/a&gt;: Entry in Martin Fowler’s bliki&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/eventstore/eventstore/wiki/Event-Sourcing-Basics&quot;&gt;Event Sourcing Basics&lt;/a&gt;: Introduction to Event Sourcing in the documentation of (Get)EventStore&lt;/li&gt;
  &lt;li&gt;Aggregates and Event Sourcing: A+ES: Appendix A contributed by Rinat Abdullin in Vaughn Vernon’s IDDD book (see below). &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/jj591559.aspx&quot;&gt;Introducing Event Sourcing&lt;/a&gt;: A chapter in the CQRS Journey e-book&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://cqrs.wikidot.com/doc:event-sourcing&quot;&gt;Event Sourcing&lt;/a&gt; in a CQRS wiki&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://cqrs.wordpress.com/documents/events-as-storage-mechanism/&quot;&gt;Events as a Storage Mechanism&lt;/a&gt;  by Greg Young&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://abdullin.com/post/event-sourcing-a-la-lokad/&quot;&gt;Event Sourcing a la Lokad&lt;/a&gt; by Rinat Abdullin&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://lostechies.com/jimmybogard/2011/10/11/event-sourcing-as-a-strategic-advantage/&quot;&gt;Event Sourcing as a strategic advantage&lt;/a&gt; by Jimmy Bogard&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://lostechies.com/jimmybogard/2014/05/13/a-better-domain-events-pattern/&quot;&gt;A better domain events pattern&lt;/a&gt; by Jimmy Bogard&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://seabites.wordpress.com/2011/02/13/aggregates-and-their-events/&quot;&gt;Aggregates and their events&lt;/a&gt; by Yves Reynhout&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://seabites.wordpress.com/2012/06/18/value-objects-in-an-eventsourced-domain-model/&quot;&gt;Value objects in an event sourced domain model&lt;/a&gt; by Yves Reynhout&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://lostechies.com/gabrielschenker/2015/05/26/event-sourcing-revisited/&quot;&gt;Event Sourcing Revisited&lt;/a&gt;,
  &lt;a href=&quot;https://lostechies.com/gabrielschenker/2015/06/06/event-sourcing-applied-the-aggregate/&quot;&gt;Event Sourcing applied - the Aggregate&lt;/a&gt;,
  &lt;a href=&quot;https://lostechies.com/gabrielschenker/2015/06/13/event-sourcing-applied-the-application-service/&quot;&gt;Event Sourcing applied – the application service&lt;/a&gt;,
  &lt;a href=&quot;https://lostechies.com/gabrielschenker/2015/07/13/event-sourcing-applied-the-repository/&quot;&gt;Event Sourcing applied – the Repository&lt;/a&gt;
  blog post series by Gabriel Schenker&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;code&quot;&gt;Code&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/NEventStore/CommonDomain&quot;&gt;NEventStore CommonDomain&lt;/a&gt;: Originally by Jonathan Oliver and now maintained as part of the NEventStore project, the CommonDomain is a great foundation for C# applications that want to use Event Sourcing and can also serve as a reference for ports into other languages.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/VaughnVernon/IDDD_Samples/tree/master/iddd_collaboration/src/main/java/com/saasovation/collaboration&quot;&gt;IDDD Sample application&lt;/a&gt;: The “Collaboration” Bounded Context of Vaughn Vernon’s sample code for this IDDD book (see below) uses event sourcing, see, e.g., the &lt;a href=&quot;https://github.com/VaughnVernon/IDDD_Samples/blob/master/iddd_collaboration/src/main/java/com/saasovation/collaboration/domain/model/forum/Discussion.java&quot;&gt;&lt;code&gt;Discussion&lt;/code&gt;&lt;/a&gt; AR derived from the &lt;a href=&quot;https://github.com/VaughnVernon/IDDD_Samples/blob/master/iddd_common/src/main/java/com/saasovation/common/domain/model/EventSourcedRootEntity.java&quot;&gt;&lt;code&gt;EventSourcedRootEntity&lt;/code&gt;&lt;/a&gt;.  This sample can get you started with Event Sourcing in Java very quickly.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/Lokad/lokad-iddd-sample&quot;&gt;Lokad IDDD Sample&lt;/a&gt;: the source code for Rinat Abdullin’s chapter in the IDDD book (C#)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/elliotritchie/NES&quot;&gt;.NET Event Sourcing&lt;/a&gt;: a lightweight framework for .NET, attempts to fill in the gaps between NServiceBus and NEventStore. &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/yreynhout/AggregateSource&quot;&gt;AggregateSource&lt;/a&gt;: A lightweight infrastructure for doing eventsourcing using aggregates in C# by Yves Reynhout; see also &lt;a href=&quot;https://github.com/yreynhout/AggregateSource/blob/master/src/Testing/AggregateSource.Testing/README.md&quot;&gt;AggregateSource Testing&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;testing&quot;&gt;Testing&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://abdullin.com/post/scenario-based-unit-tests-for-ddd-with-event-sourcing/&quot;&gt;Scenario-based Unit Tests for DDD with Event Sourcing&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://pkaczor.blogspot.de/2013/11/axon-framework-behaviour-driven-testing.html&quot;&gt;Axon framework - behavior driven testing&lt;/a&gt; - we are not using Axon, but the BDD Given–When–Then pattern presented is quite powerful&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://seabites.wordpress.com/2013/11/26/trenchtalk-assertthatweunderstand/&quot;&gt;Trench Talk: &lt;code&gt;Assert.That(We.Understand());&lt;/code&gt;&lt;/a&gt; by Yves Reynhout on BDD testing with ES&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;event-store&quot;&gt;Event Store&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://cqrs.wordpress.com/documents/building-event-storage/&quot;&gt;Building an Event Storage&lt;/a&gt; by Greg Young&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://eaipatterns.com/docs/IEEE_Software_Design_2PC.pdf&quot;&gt;Your Coffee Shop Doesn’t Use Two-Phase Commit&lt;/a&gt; by Gregor Hope&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.jonathanoliver.com/how-i-avoid-two-phase-commit/&quot;&gt;How I Avoid Two-Phase Commit&lt;/a&gt; and &lt;a href=&quot;http://blog.jonathanoliver.com/removing-2pc-two-phase-commit/&quot;&gt;Removing 2PC (Two Phase Commit)&lt;/a&gt;: Jonathan Oliver on how NEventStore avoids expensive 2PCs&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://seabites.wordpress.com/2011/12/07/your-eventstream-is-a-linked-list/&quot;&gt;Your EventStream is a linked list&lt;/a&gt; by Yves Reynhout&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;code-1&quot;&gt;Code&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/NEventStore/NEventStore&quot;&gt;NEventStore&lt;/a&gt;: The implementation of the popular event store for .NET is a must-read:  It’s very well designed and the code is easy to understand.  It can serve as a template for implementation in other languages — in fact, our own &lt;a href=&quot;https://github.com/JEEventStore/JEEventStore&quot;&gt;JEEventStore&lt;/a&gt; was heavily influenced by it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;cqrs-including-cqrses&quot;&gt;CQRS (including CQRS+ES)&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://dddcqrs.googlegroups.com&quot;&gt;DDDCQRS mailing list&lt;/a&gt;: Worth reading the archive.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://martinfowler.com/bliki/CQRS.html&quot;&gt;CQRS&lt;/a&gt;: Entry in Martin Fowler’s bliki&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.allthingsdistributed.com/2008/12/eventually_consistent.html&quot;&gt;Eventually Consistent - Revisited&lt;/a&gt; article by Werner Vogel, CTO of Amazon&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/jj554200.aspx&quot;&gt;CQRS Journey&lt;/a&gt; long e-book on CQRS by a Microsoft team, a must-read&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.infoq.com/presentations/Command-Query-Responsibility-Segregation&quot;&gt;Command-Query Responsibility Segregation&lt;/a&gt;: video/slides of a talk by Udi Dahan at QCon&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.cqrs.nu/&quot;&gt;CQRS Starter Kit and FAQ&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.udidahan.com/2009/12/09/clarified-cqrs/&quot;&gt;Clarified CQRS&lt;/a&gt; by Udi Dahan&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://lostechies.com/jimmybogard/2012/08/22/busting-some-cqrs-myths/&quot;&gt;Busting some CQRS myths&lt;/a&gt; by Jimmy Bogard — definitely worth reading
]&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.udidahan.com/2011/10/02/why-you-should-be-using-cqrs-almost-everywhere%E2%80%A6/&quot;&gt;Why you should be using CQRS almost everywhere…&lt;/a&gt; by Udi Dahan&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.udidahan.com/2011/04/22/when-to-avoid-cqrs/&quot;&gt;When to avoid CQRS&lt;/a&gt; by Udi Dahan&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://cqrs.wordpress.com/documents/cqrs-and-event-sourcing-synergy/&quot;&gt;CQRS and Event Sourcing&lt;/a&gt; by Greg Young&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.jonathanoliver.com/why-i-still-love-cqrs-and-messaging-and-event-sourcing/&quot;&gt;Why I Still Love CQRS (and Messaging and Event Sourcing)&lt;/a&gt; by Jonathan Oliver on benefits of CQRS+ES, many links included&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://blog.jonathanoliver.com/cqrs-out-of-sequence-messages-and-read-models/&quot;&gt;CQRS: Out of Sequence Messages and Read Models&lt;/a&gt; by Jonathan Oliver&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://lostechies.com/jimmybogard/2012/08/23/cqrs-and-user-experience/&quot;&gt;CQRS and user experience&lt;/a&gt; by Jimmy Bogard&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://eventuallyconsistent.net/2012/08/24/cqrs-use-your-common-sense/&quot;&gt;CQRS – Use Your Common Sense&lt;/a&gt; by Steve Bate&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://stackoverflow.com/questions/9495985/cqrs-event-sourcing-validate-username-uniqueness&quot;&gt;CQRS Event Sourcing: Validate UserName uniqueness&lt;/a&gt;: Stackoverflow question on a very common use-case: uniqueness constraints&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://codebetter.com/gregyoung/2010/08/12/eventual-consistency-and-set-validation/&quot;&gt;Eventual Consistency and Set Validation&lt;/a&gt;: Greg Young on uniqueness constraints&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://seabites.wordpress.com/2010/11/11/consistent-indexes-constraints/&quot;&gt;Secondary indexes and constraints on the write side&lt;/a&gt;: Yves Reynhout on uniqueness constraints&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;code-samples&quot;&gt;Code Samples&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/gregoryyoung/m-r/tree/master/SimpleCQRS&quot;&gt;Greg Young’s SimpleCQRS example&lt;/a&gt;: small C# sample project that let’s one quickly grasp the CQRS principle&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://lokad.github.io/lokad-cqrs/&quot;&gt;Lokad.CQRS Sample Project&lt;/a&gt; An advanced (and complex) CQRS sample project&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/mspnp/cqrs-journey-code&quot;&gt;CQRS Journey Code&lt;/a&gt;: the CQRS Journey sample application for the e-book&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/tyronegroves/SimpleCQRS&quot;&gt;SimpleCQRS&lt;/a&gt; by Tyrone Groves (C#)&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;ddd&quot;&gt;DDD&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.amazon.com/dp/0321125215&quot;&gt;Domain Driven Design&lt;/a&gt;: &lt;em&gt;The&lt;/em&gt; blue book by Eric J. Evans&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.amazon.com/dp/0321834577&quot;&gt;Implementing Domain Driven Design&lt;/a&gt;:  A book by Vaughn Vernon, which I can recommend even more than Evan’s original book;  if you want to read only one book on the topic, read this.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.udidahan.com/2009/06/29/dont-create-aggregate-roots/&quot;&gt;Don’t Create Aggregate Roots&lt;/a&gt; by Udi Dahan&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.cqrs.nu/Faq/aggregates&quot;&gt;FAQ on Aggregates&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.cqrs.nu/Faq/sagas&quot;&gt;FAQ on Sagas&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;messaging&quot;&gt;Messaging&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://martinfowler.com/articles/lmax.html&quot;&gt;The LMAX disruptor&lt;/a&gt;: Entry in Martin Fowler’s bliki.  The LMAX disruptor a high-performance, single-threaded messaging architecture for the JVM that for a financial application handles up to 6 million order per second.  Even if such scalability is way out of scope of most projects, you should be aware of it.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/Particular/NServiceBus&quot;&gt;NServiceBus&lt;/a&gt;: The most popular service bus for .NET.  If you are going to use CQRS+ES in a C# project, you should look at this.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;updates-to-this-post&quot;&gt;Updates to this post&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;2015-07-15: Added Gabriel Schenker’s blog series on Event Sourcing.&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Building an Event Store for Java</title>
   <link href="http://blog.langer.eu/2014/09/02/event-store-for-java.html"/>
   <updated>2014-09-02T00:00:00+00:00</updated>
   <id>http://blog.langer.eu/2014/09/02/event-store-for-java</id>
   <content type="html">&lt;p&gt;A common legal requirement in the area of medical software is that the change history of medical health records must be kept available.  With traditional relational databases, we used a one-revision–one-row approach, storing each revision of a record in a single row and having an extra field in the table point to the previous revision. This was working fine but put a significant amount of burden onto the development team.&lt;/p&gt;

&lt;p&gt;When I learned about the concept of &lt;a href=&quot;http://martinfowler.com/eaaDev/EventSourcing.html&quot;&gt;Event Sourcing&lt;/a&gt;, I figured that it fits naturally with these requirements, since reliable change history is given for free; in particular, obtaining the state of the whole system at a given time in the past is almost trivial. (Only much later we learned to love the additional benefits of event sourcing.) For a new project, we therefore decided to go the event sourcing path.  For that, we were looking for an &lt;a href=&quot;https://github.com/eventstore/eventstore/wiki/Event-Sourcing-Basics#what-is-an-event-store&quot;&gt;Event Store&lt;/a&gt; that we can integrate with our technology stack, which is based around Java EE (development done on Mac OS X or Linux and the production servers running Linux).&lt;/p&gt;

&lt;h1 id=&quot;existing-event-stores&quot;&gt;Existing Event Stores&lt;/h1&gt;

&lt;h2 id=&quot;net&quot;&gt;.NET&lt;/h2&gt;

&lt;p&gt;The .NET-community has quickly adopted Event Sourcing (most often combined with
&lt;a href=&quot;http://martinfowler.com/bliki/CQRS.html&quot;&gt;CQRS&lt;/a&gt;, i.e., CQRS+ES), and it is therefore not surprising that there are at least two mature open-source event stores for .NET.  The two most popular ones are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/NEventStore/NEventStore&quot;&gt;NEventStore&lt;/a&gt;, originally developed by &lt;a href=&quot;https://github.com/joliver&quot;&gt;Jonathan Oliver&lt;/a&gt;, now maintained by &lt;a href=&quot;https://github.com/andreabalducci&quot;&gt;Andrea Balducci&lt;/a&gt;, &lt;a href=&quot;https://github.com/damianh&quot;&gt;Damian Hickey&lt;/a&gt;, and &lt;a href=&quot;https://github.com/kblooie&quot;&gt;Jonathan Matheus&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://geteventstore.com&quot;&gt;EventStore&lt;/a&gt; by &lt;a href=&quot;https://github.com/gregoryyoung&quot;&gt;Greg Young&lt;/a&gt; and his team&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If our technology stack was Windows with .NET, we would most definitely use one of these two, in particular since you can buy SLAs for EventStore. However,  .NET is simply not an option for us, since we do not want the vendor lock-in that comes with .NET. (Sorry, Mono, we’re &lt;a href=&quot;http://techrights.org/2008/12/23/second-class-novellsoft-ide/&quot;&gt;not going to&lt;/a&gt; &lt;a href=&quot;https://news.ycombinator.com/item?id=5042192&quot;&gt;use you&lt;/a&gt; &lt;a href=&quot;http://blog.jonathanoliver.com/why-i-left-dot-net/#mono&quot;&gt;in production&lt;/a&gt;.)  Furthermore, due to Germany’s strict data protection laws, we cannot use a cloud solution.  For medical software, local deployments are a must.&lt;/p&gt;

&lt;h2 id=&quot;java--jvm&quot;&gt;Java / JVM&lt;/h2&gt;

&lt;p&gt;I therefore evaluated the event stores that are available for the JVM.  In 2013 (the situation hasn’t change much since), I was aware of the following projects that provide an event store, in some form or another:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.axonframework.org/&quot;&gt;Axon Framework&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://qi4j.org/&quot;&gt;Qi4j&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://en.jdon.com/&quot;&gt;JDON&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/eligosource/eventsourced&quot;&gt;Eligo Eventsourced&lt;/a&gt;, now superseded by &lt;a href=&quot;http://doc.akka.io/docs/akka/snapshot/scala/persistence.html&quot;&gt;Akka Persistence&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/ks-no/eventstore2&quot;&gt;EventStore2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;eventstore2&quot;&gt;EventStore2&lt;/h3&gt;

&lt;p&gt;EventStore2 is a standalone event store, but it’s built upon Akka, whose threading model conflicts with JEE containers. Furthermore, its interface depends on its &lt;code&gt;Event&lt;/code&gt; class, meaning you’d introduce a technical dependency on the event store library into your domain model, which is a no-go for a &lt;a href=&quot;http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html&quot;&gt;clean architecture&lt;/a&gt;. We might have been able to fork the project and refactor this, but the dependency on Akka remains.&lt;/p&gt;

&lt;h3 id=&quot;axon-jdon-qi4j-akka-persistence&quot;&gt;Axon, JDON, Qi4j, Akka (Persistence)&lt;/h3&gt;

&lt;p&gt;None of Axon, JDON, Qi4J nor Akka is a standalone event store in the style of the .NET projects EventStore and NEventStore.  Rather, these are frameworks that each solve a different problem:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Axon and JDON are CQRS+ES frameworks, where the event store is necessary infrastructure.&lt;/li&gt;
  &lt;li&gt;Akka Persistence is a library that provides event sourcing for applications using the Actor programming model of Akka.&lt;/li&gt;
  &lt;li&gt;Qi4j is an implementation of the &lt;a href=&quot;http://en.wikipedia.org/wiki/Data,_context_and_interaction&quot;&gt;DCI&lt;/a&gt; paradigm for Java.  An event sourcing mixin is provided, which, as of today, &lt;a href=&quot;http://qi4j.org/2.0/library-eventsourcing.html&quot;&gt;lacks documentation&lt;/a&gt;. However, adding mixins to Java is arguably magic, at the least non-standard and most probably completely unportable — good luck migrating your application later or introducing new team members.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Consequently, because of their broader focus, Axon, JDON, and Qi4j require you to annotate your domain model with framework annotations, which, as above, means introducing a strong technical dependency into your domain model.  In particular, let me stress that your domain model is not even testable without these annotations, i.e., without using the framework.  Again, this violates the principles of a clean architecture, where your domain model is supposed to have absolutely no dependencies to “outer” layers (particularly not on infrastructure concerns such as persistence).&lt;/p&gt;

&lt;p&gt;Furthermore, Axon and Akka apparently require you to derive your domain classes from certain base classes provided by the framework.  To quote a very recent blog post by Dariusz Pasciak in the 8th Light blog, entitled &lt;a href=&quot;http://blog.8thlight.com/dariusz-pasciak/2014/08/27/convenient-does-not-necessarily-mean-right.html&quot;&gt;&lt;em&gt;‘Convenient’ Does Not Necessarily Mean ‘Right’&lt;/em&gt;&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;If you are using a framework in which you are required to derive from some base class and then call methods on that base class in order to accomplish something that you are trying to accomplish, and the framework designers have provided inheritance as the only way of accomplishing this thing that you are trying to accomplish, and you are comfortable with forming such a strong relationship [footnote: Inheritance is one of the strongest forms of coupling in object-oriented code.] with that framework—then deriving your class from some other class that has methods on it that you would like to use may be right.
&lt;cite&gt;Dariusz Pasciak&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;building-an-event-store-for-java-ee&quot;&gt;Building an Event Store for Java EE&lt;/h2&gt;

&lt;p&gt;Due to the lack of suitable event stores for Java that can easily be used in a Java EE environment, we decided to build our own, called &lt;a href=&quot;https://github.com/JEEventStore/JEEventStore&quot;&gt;JEEventStore&lt;/a&gt;.  In a series of upcoming posts, I’m going to write up the design rationale for our event store, wish-list and feature set, describe its architecture and will tell you how to use it in your own project.&lt;/p&gt;
</content>
 </entry>
 
 
</feed>
