开发者

Wiring up JOliver's EventStore using RavenDB Persistence Plugin

开发者 https://www.devze.com 2023-03-08 15:12 出处:网络
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

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 = 开发者_Python百科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?


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();


private IStoreEvents GetInitializedEventStore(IDispatchCommits bus)
    {
        return Wireup.Init()
            .UsingRavenPersistence(BootStrapper.RavenDbEventStoreConnectionStringName)
            .UsingAsynchronousDispatchScheduler(bus)
            .Build();
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消