【问题标题】:Wiring up JOliver's EventStore using RavenDB Persistence Plugin使用 RavenDB 持久性插件连接 JOliver 的 EventStore
【发布时间】:2012-01-09 19:20:33
【问题描述】:

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

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

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

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

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

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

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

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

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

【问题讨论】:

    标签: c# .net ravendb cqrs event-sourcing


    【解决方案1】:

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

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

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

    【讨论】:

    • 感谢您的回答!我明白你对 Raven 不需要序列化程序的意思。是的,我现在确实省略了一个调度程序,因为我试图一次找出一个 EventStore。但肯定是下一步。
    • 我已更新 Raven 连线代码以返回 PersistenceWireup 实例。
    • 这不再有效。有没有使用最新版本的示例?
    【解决方案2】:
    private IStoreEvents GetInitializedEventStore(IDispatchCommits bus)
        {
            return Wireup.Init()
                .UsingRavenPersistence(BootStrapper.RavenDbEventStoreConnectionStringName)
                .UsingAsynchronousDispatchScheduler(bus)
                .Build();
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-21
      • 1970-01-01
      相关资源
      最近更新 更多