Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nservicebus 是什么导致EventStore如此容易抛出ConcurrencyException?_Nservicebus_Cqrs_Neventstore - Fatal编程技术网

Nservicebus 是什么导致EventStore如此容易抛出ConcurrencyException?

Nservicebus 是什么导致EventStore如此容易抛出ConcurrencyException?,nservicebus,cqrs,neventstore,Nservicebus,Cqrs,Neventstore,使用3.0,刚刚开始使用简单的示例 我使用NServiceBus实现了一个简单的pub/sub-CQRS。客户端在总线上发送命令,域服务器接收并处理命令,并将事件存储到eventstore,然后eventstore的dispatcher在总线上发布这些事件。然后,读取模型服务器订阅这些事件以更新读取模型。没什么特别的,都是照本宣科的 它正在工作,但仅在简单的测试中,当事件存储到EventStore时,我在域服务器上就得到了大量并发异常(间歇性)。它会正确地重试,但有时会达到5次重试的限制,并且该

使用3.0,刚刚开始使用简单的示例

我使用NServiceBus实现了一个简单的pub/sub-CQRS。客户端在总线上发送命令,域服务器接收并处理命令,并将事件存储到eventstore,然后eventstore的dispatcher在总线上发布这些事件。然后,读取模型服务器订阅这些事件以更新读取模型。没什么特别的,都是照本宣科的

它正在工作,但仅在简单的测试中,当事件存储到EventStore时,我在域服务器上就得到了大量并发异常(间歇性)。它会正确地重试,但有时会达到5次重试的限制,并且该命令最终会出现在错误队列中

我可以从哪里开始调查,看看是什么导致了并发异常?我删除了dispatcher,只关注于存储事件,它也有同样的问题

我正在使用RavenDB来持久化我的EventStore。我没有做任何花哨的事,只是这样:

使用(var stream=eventStore.OpenStream(entityId,0,int.MaxValue))
{
Add(新事件消息{Body=myEvent});
stream.CommitChanges(Guid.NewGuid());
}
异常的堆栈跟踪如下所示:

2012-03-17 18:34:01166[工人14]警告 NServiceBus.Unicast.UnicastBus[(null)]- EmployeeCommandHandler无法处理消息。 EventStore.ConcurrencyException:类型为的异常 已引发“EventStore.ConcurrencyException”。在 中的EventStore.OptimisticPipelineHook.PreCommit(提交尝试) c:\Code\public\EventStore\src\proj\EventStore.Core\OptimisticPipelineHook.cs:line 55在EventStore.OptimisticEventStore.Commit中提交(提交尝试) c:\Code\public\EventStore\src\proj\EventStore.Core\OptimisticEventStore.cs:line 90在EventStore.OptimisticEventStream.PersistChanges(Guid 委员会)在 c:\Code\public\EventStore\src\proj\EventStore.Core\OptimisticEventStream.cs:line 168在EventStore.OptimisticEventStream.CommitChanges(Guid 委员会)在 c:\Code\public\EventStore\src\proj\EventStore.Core\OptimisticEventStream.cs:line 149位于CQRSTest3.Domain.Extensions.StoreEvent(iStoreeEvents 事件存储,Guid entityId,对象evt)在 C:\dev\test\CQRSTest3\CQRSTest3.Domain\Extensions.cs: CQRSTest3.Domain.ComandHandlers.EmployeeCommandHandler.Handle(ChangeEmployeeSalary 信息)在 C:\dev\test\CQRSTest3\CQRSTest3.Domain\ComandHandlers\Emplo yeeCommandHandler.cs:第55行


我想出来了。但是,我们必须通过挖掘源代码来找到它。我希望这是更好的记录!以下是我的新eventstore wireup:

EventStore = Wireup.Init()
          .UsingRavenPersistence("RavenDB")
          .ConsistentQueries()
          .InitializeStorageEngine()
          .Build();
我必须添加.ConsistentQueries(),以便raven持久性提供程序在内部对eventstore向raven发出的查询使用WaitForNonSaleResults


基本上,当我添加一个新事件,然后在raven完成索引之前尝试添加另一个事件时,流修订不是最新的。第二个事件将发生在第一个事件上。

使用sql存储重试测试,以查看并发问题是否与RavenDb集成有关?查找该问题的额外要点。EventStore中的下一步是更好的文档。很高兴看到该方法至少可用。一旦我发现这是由于陈旧的查询结果造成的,我就担心我必须破解eventstore源代码。我期待新的文档。:)@JonathanOliver我没有使用eventstore,只是在不久前偶然发现了这一点。那时我对瑞文还不熟悉,但现在我更沉浸在其中了。您应该更改
.consistentQueries()
实现
.waitForNonSaleResults()
在生产中非常糟糕。您将在繁忙的系统上永远等待。您可能应该使用
.WaitForNonStaleResultsAsOfNow()
来提供一个中断。@MattJohnson我想最好使用
.waitfornonstaleresultsaflastwrite()
,这不会迫使我们等待其他客户端。更多信息请点击此处: