Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wiring up JOliver's EventStore using RavenDB Persistence Plugin

I am evaluating JOliver's EventStore library. In particular, I am trying to use RavenDB as the persistence engine for EventStore. EventStore comes with a plugin for this. NOTE: The database is empty with no indexes (other than the default ones).

In wiring up the store, I used the following:

var store = Wireup.Init()
    .UsingRavenPersistence("EventStore", new DocumentObjectSerializer())
    .Build();

However, when I run my program, I get an exception that indicates the "RavenCommitByRevisionRange" index could not be found.

In digging around the EventStore code, I think the problem happens to be that the RavenPersistenceEngine is not being initialized. The initialization code installs the needed indexes in the RavenDB server.

On the SQL server side of things, I noticed that the wiring code in the example project shows a call to an extension method called: "InitializeStorageEngine". This extension method is tied to the class "PersistenceWireup". However, the extension method I'm using to wire in RavenDB persistence returns the class "Wireup". So I wrapped part of my wireup code in a new PersistenceWireup instance, and was able to call ".InitializeStorageEngine()" like so:

var store = new PersistenceWireup(
    Wireup.Init()
        .UsingRavenPersistence("EventStore", new DocumentObjectSerializer()))
            .InitializeStorageEngine()
        .Build();

This works great! The RavenDB database now contained the necessary indexes.

So... My questions: Shouldn't ".UsingRavenPersistence(...)" return an instance of "PersistenceWireup" rather than simply "Wireup"? Or is there a better way to wire up RavenDB persistence in EventStore?

like image 914
Lee DeLapp Avatar asked May 25 '11 20:05

Lee DeLapp


1 Answers

Hmmm. Well, I think that the reason raven doesn't implement PersistenceWireup is b/c that interface exposes ISerializer specific methods which the document store implementations don't use. We probably need to move the initialize to Wireup. I'll look into this.

However, I see that you're missing the dispatcher that will dispatch the event after storage. Was this intentional? If you're not planning on publishing from another enpoint, the add the Synchronous / Asynchronous dispatcher. The dispatcher is currently calling initialize.

Wireup.Init()
.UsingRavenPersistence("EventStore", new DocumentObjectSerializer())
.UsingSynchronousDispatcher()
.PublishTo(new DelegateMessagePublisher(c => PublishMessages(c))
.Build();
like image 155
Jonathan Matheus Avatar answered Nov 15 '22 04:11

Jonathan Matheus