5

我正在评估JOliver 的 EventStore库。特别是,我正在尝试使用RavenDB作为 EventStore 的持久化引擎。EventStore 附带了一个插件。注意:数据库是空的,没有索引(默认索引除外)。

在连接商店时,我使用了以下内容:

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

但是,当我运行我的程序时,我得到一个异常,表明找不到“RavenCommitByRevisionRange”索引。

在挖掘 EventStore 代码时,我认为问题恰好是 RavenPersistenceEngine 没有被初始化。初始化代码在 RavenDB 服务器中安装所需的索引。

在 SQL Server 方面,我注意到示例项目中的接线代码显示了对名为“InitializeStorageEngine”的扩展方法的调用。此扩展方法与“PersistenceWireup”类相关联。但是,我用来连接 RavenDB 持久性的扩展方法返回类“Wireup”。所以我将部分连线代码包装在一个新的 PersistenceWireup 实例中,并且能够像这样调用“.InitializeStorageEngine()”:

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

这很好用!RavenDB 数据库现在包含必要的索引。

所以...我的问题:“.UsingRavenPersistence(...)”不应该返回“PersistenceWireup”的实例,而不仅仅是“Wireup”吗?或者有没有更好的方法在 EventStore 中连接 RavenDB 持久性?

4

2 回答 2

5

嗯。好吧,我认为 raven 没有实现 PersistenceWireup 的原因是接口暴露了文档存储实现不使用的 ISerializer 特定方法。我们可能需要将初始化移动到 Wireup。我会调查一下。

但是,我看到您缺少将在存储后调度事件的调度程序。这是故意的吗?如果您不打算从另一个端点发布,请添加同步/异步调度程序。调度程序当前正在调用初始化。

Wireup.Init()
.UsingRavenPersistence("EventStore", new DocumentObjectSerializer())
.UsingSynchronousDispatcher()
.PublishTo(new DelegateMessagePublisher(c => PublishMessages(c))
.Build();
于 2011-05-26T05:44:55.500 回答
2
private IStoreEvents GetInitializedEventStore(IDispatchCommits bus)
    {
        return Wireup.Init()
            .UsingRavenPersistence(BootStrapper.RavenDbEventStoreConnectionStringName)
            .UsingAsynchronousDispatchScheduler(bus)
            .Build();
    }
于 2012-01-09T11:20:33.700 回答