gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 23:02:50 25 4
gpt4 key购买 nike

我正在评估 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com