.NET Event Sourcing
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
samples
src
tools
.gitattributes
.gitignore
README.markdown
build.bat
default.ps1
license.txt

README.markdown

NES v5

NES (.NET Event Sourcing) is a lightweight framework that helps you build domain models when you're doing event sourcing.

What

If you're looking to take advantage of event sourcing on the .NET platform then you may also be looking to use NServiceBus and NEventStore. NES is an attempt to fill in the gaps between these two frameworks.

Why

The code required to bring NServiceBus and NEventStore together isn't hard to write but it is important and it does have to work a certain way to take full advantage of both frameworks. There's some great resources out there already that help you write this yourself but ideally you'd want to concentrate on developing your domain model's behaviour rather than the infrastructure to glue these two frameworks together.

How

NES hooks into NServiceBus' and NEventStore's configuration objects and transparently takes care of everything for you. All you have to do is add two extra lines to your application's initialisation code.

Project Goals

  • Allow processing of messages sent in a batch as a single transaction (Ref)
  • Allow use of interfaces for events (Ref)
  • Allow up-conversion of events (Ref @ 36:00)
  • Automatic persistence of message headers
  • Automatic publishing of persisted events
  • Convention based event handling within aggregates
  • No 'Save()' methods on repositories
  • Minimal configuration

Version History

v5

  • Supports NEventStore v5
  • Supports NServiceBus v5

v4

  • Supports NEventStore v4
  • Supports NServiceBus v4

v3

  • Supports EventStore v3
  • Supports NServiceBus v3

v2

  • Supports EventStore v3
  • Supports NServiceBus v2

v1

  • Supports EventStore v2
  • Supports NServiceBus v2

Download

The easiest way to install NES is via NuGet (NES, NES.NEventStore, NES.NEventStore.Raven, NES.NServiceBus) or you can download the source and run 'build.bat' from the command line. Once built, the files will be placed in the 'build' folder.

Using NES until Version 4

public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
	public void Init()
	{
		NEventStore.Wireup.Init()
			.UsingSqlPersistence("EventStore")
			.InitializeStorageEngine()
			.NES()
			.UsingJsonSerialization()
			.Build();

		NServiceBus.Configure.With()
			.Log4Net()
			.DefaultBuilder()
			.JsonSerializer()
			.NES();
	}
}

Using NES from version 5

public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, IWantToRunWhenBusStartsAndStops, IWantToRunWhenConfigurationIsComplete
    {
        public void Init()
        {
            LogManager.Use<Log4NetFactory>();
        }

        public void Start()
        {
            Wireup.Init()
                .UsingInMemoryPersistence()
                .EnlistInAmbientTransaction()
                .NES()
                .Build();
        }

        public void Stop()
        {
        }

        public void Customize(BusConfiguration configuration)
        {
            configuration.UseSerialization<Json>();
            configuration.EnableInstallers();
            configuration.UsePersistence<InMemoryPersistence>();
            configuration.UseTransport<MsmqTransport>();
            configuration.PurgeOnStartup(false);
        }

        public void Run(Configure config)
        {
            config.NES();
        }
    }

If you customize the BusConfiguration in a way, that you are defining which assemblies should be loading like following

configuration.AssembliesToScan(AllAssemblies.Matching("MyNamespace"));

so please ensure, that also all NES assemblies are loaded as well. You will get NullReferenceException if not doing so.

For a more complete example, please open and build NES.Sample.sln in Visual Studio and hit F5. This will start the NES.Sample NServiceBus endpoint as well as the NES.Sample.Web MVC3 website.

Need help? Found a bug? Have a question?

  • For guidance on how to use NES please take a look at the wiki pages.
  • If you have any problems using NES please submit a new issue.
  • Ask your question on Stack Overflow and tag your question with the CQRS tag and the word "NES" in the title.