Skip to content

Episode 4 – Event Sourcing Basics

2012 August 31
by Kerry Street

Event Sourcing Basics (a day in the car factory). Kerry and Rinat review questions about designing command and event messages and then introduce the new topic of Event Sourcing. We model one day at the Factory using event sourcing, domain language and concepts discussed in earlier episodes.

Direct Download link: Episode 4 – Event Sourcing Basics – (66 minutes)

Subscribe via RSS | Subscribe for free in iTunes

Here’s the car factory implementation diagram, referenced in this episode:

Car Factory Implementation Plan


  • CSharp developers: implement 2 remaining methods of Factory using event sourcing
  • other languages: reimplement Sample E004 in your own language


What do you think?

16 Responses Post a comment
  1. Tim Dunnington permalink
    August 31, 2012

    Hey guys, you weren’t on the Zune marketplace, which means I couldn’t pull up your podcast on my Windows phone using the built-in podcast app.

    I just went ahead and submitted your feed URL to the Zune Marketplace (there’s a button on this page


    • Kerry Street permalink*
      August 31, 2012

      So what you are saying is, even though we don’t work at the same place anymore, you are STILL solving my problems? :) Thanks a lot buddy, appreciate the help. See you at the conf in a couple months!

  2. Mikhail Zelenin permalink
    September 4, 2012

    Hello guys, may be it better to split discussion of previous topic and new one on two separate episodes. It will help with 30 minutes time-boxing )

    And Rinat please sometimes use “basically” instead of “in essence” :))))

    Thank you a lot!

    • Rinat Abdullin permalink*
      September 7, 2012

      Mikhail, thanks. Will try to do that.

  3. Jason Wyglendowski permalink
    September 4, 2012

    I just finished listening to the episode on my way home from work and found that it complemented well the code examples which I actually went through prior to listening to the podcast. Kerry your comments and questions are well stated and are in line what I would have asked if I was sitting in on the podcast. The trick in Rinat’s code

    ((dynamic) this).AnnounceInsideFactory((dynamic) e);

    This could also be accomplished without the dynamic keyword and if statements though it does require another line of code.

    Dim _event as Object = e

    I would agree with Rinat that shorter say 20 to thirty minute podcasts are probably better but I would suggest that maybe every four or so podcasts do one that is in the say 45 minutes to hour just dedicated to reviewing concepts and discussing perhaps homework assignments.

    Kerry my order is in for a Zenbook and hopefully it will be in by the weekend so I can start providing some VB.NET code. Once I get my laptop I will setup up a GIT HUB account. So would I just do a pull request using the new VS tools from git then share the link with you guys? How does that work? Since I work as a team one I have never had the need to use distributed source control.

    Anyway thanks and A Plus for now. Jason..

    • Kerry Street permalink*
      September 5, 2012

      Thanks for the feedback Jason. In the next episode we actually do plan to do what you mentioned, review the “homework” code from episode 4 and 5, answer some questions we have received, and not introduce a new concept. The concepts we have covered so far are so important to everything else that we don’t want to rush past them.

      Re: git/GitHub, until we can get around to posting something more detailed (or discussing it): I wouldn’t use the VS 2012 git stuff yet because I am not sure if it is TFS only or how that works yet. For a Windows user that has never used git/GitHub, I highly recommend that you 1) get a free GitHub account. 2) go to: and install GitHub for Windows. It is a nice native Windows app that will also install and maintain its own copy of git and make logical initial setup decisions for you. 3) Open our samples page at and click the “Clone in Windows” button. This will put a copy of our samples into YOUR GitHub account on their site AND on your local machine where you can easily open it up and start to add to it. Let us know when you get to that point and we can give some guidance on how we would like the other languages to be structured within the core sample (TBD).

      Thanks for participating.

      • Jason Wyglendowski permalink
        September 5, 2012

        Thanks for the reply. Once I get my machine setup I will follow Rinat’s structure keeping it consistent until told otherwise. After I get it setup I will send you the link to the repo. A Plus Jason.

  4. Oleg permalink
    September 6, 2012

    Rinat, in Episode 2 you used messages to add poroducts to the basket. And products were added in the particulat message handler method. Probably I’m not getting the point, but in this episode repository is changed by events. So if I correctly understand, the message i.e. the handler of the message could produce few events and state variables should be changed only in the internal events hamdlers. And should be changed only if event was correctly written to the evet store. Right?

    • Rinat Abdullin permalink*
      September 7, 2012

      Oleg, in episode 2 we were not even talking about event sourcing, rather dealing with basic messaging paradigms.

      Yes, in this episode we move to event sourcing and change is in the events. Since changes are actually persisted as events, so if events were not correctly written to the event store, to they didn’t even happen.

      State variables can be changed by events, as they are passed to the in-memory list of events to be saved. However, these changes are transient. If server crashes before this change list is saved, then the entire change set is never committed (it didn’t happen)

      • Oleg permalink
        September 7, 2012

        Rinat, thank you for the reply. Now it’s clear to me.

  5. Jason Wyglendowski permalink
    September 10, 2012

    I have lesson 004 code in VB.NET complete at if anyone interested. A Plus Jason…

    • Kerry Street permalink*
      September 11, 2012

      Thanks Jason. I just migrated your code into the Being The Worst GitHub org and into its own VB.NET repo. I set the directories and solution up to be very similar to our C# reference example and added a few other files that the C# samples had. Can you please fork the repo from our BTW organization and see if your code still runs as you designed it? Once you fork it and make future changes in your fork, you can then submit a pull request to us and we can accept your changes right into the BTW org’s VB.NET repo. I also assigned to the code our default New BSD License. Can you please reply here and ack that you are ok with that and the above changes? Thanks!

      • Jason Wyglendowski permalink
        September 11, 2012

        I have cloned the new repo as requested. Once I finish lesson five and I will update my repo and submit a pull request. If I have any issues I leave a comment here in this lesson. By the way Kerry I am enjoying coding on my Asus UX31E ultrabook. The portability is superb and the screen 1600 X 900 resolution really helps when I have multiple windows open like in Visual Studio. A Plus for now…. Jason

  6. October 12, 2012

    Could you elaborate a bit on how you deal with command persistence?

    Do you persist the command to the event store as a “command issued event” or do you persist those somewhere entirely separately?

    • Rinat Abdullin permalink*
      October 13, 2012

      Kim, if you refer to persistence of commands for the audit purposes, then we just dump them into a stream called “audit”. Technically event store is just a message store, that can persist whatever you are throwing at it.

      The only trick is to make sure that you skip this “audit” stream while replaying everything to rebuild projections.

      • October 14, 2012

        Thanks, that makes a lot of sense! I guess you persist the command to the audit stream before doing any actual processing to avoid ending up in the awkward position where a command has done something nasty and then the command audit step failed for whatever reason?

        A piece of infrastructure like the event store should be perfect for the auditing use case. I’ve looked through some of the source code of Greg’s event store and I see that he has introduced a “causation id” concept that would fit nicely with this. With all this in place it should be possible to create pretty cool auditing / administration tools plotting all the commands and events as a graph :-)

        I was thinking about persisting commands in the event store on my way to work the other day and I guess I took it (at least) one step to far in my mind. I was considering whether it would be possible to use the event store as a queue for dispatching commands to application services, but I couldn’t come up with a safe way to keep track of processed and failed commands without introducing a unit of work concept. Perhaps it’s better to use an existing queue implementation for this after all..

Leave a Reply

Note: You may use basic HTML in your comments. Your email address will not be published.

Subscribe to this comment feed via RSS