c# - 使用 RavenDB 持久性插件连接 JOliver 的 EventStore

标签 c# .net ravendb cqrs event-sourcing

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

在为商店布线时,我使用了以下内容:

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

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

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

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

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

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

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

最佳答案

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

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

Wireup.Init()
.UsingRavenPersistence("EventStore", new DocumentObjectSerializer())
.UsingSynchronousDispatcher()
.PublishTo(new DelegateMessagePublisher(c => PublishMessages(c))
.Build();

关于c# - 使用 RavenDB 持久性插件连接 JOliver 的 EventStore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6130790/

相关文章:

c# - Entity Framework - 无法从使用中推断出来

c# - 无法使用 Effort 框架在单元测试中使用现有数据库

c# - 如何将 WebService 添加到 C# WinForm?

c# - Regex.Replace 在 html 字符串中查找可变宽度和高度并替换为设置值

.net - 如何从.Net Web服务返回数据表?

c# - 选择数据库结构/引擎的指南

c# - 如何获取和设置 WPF 文本框的当前光标位置

c# - 线程并行调用、操作

database - RavenDB 的性能问题

java - 使用泛型返回 RavenDB StreamResult