我正在使用 EventStore,一切似乎都在工作,事件由我的内存代理存储和调度,事件由我的读取模型处理。但是由于某种原因,EventStore Commits 表中的“已调度”标志没有设置,所以每次我重新启动我的应用程序时,它都会重播所有事件。我使用 SQL Server 2012 作为存储。没有发生错误。知道为什么这个标志不会被设置吗?
我的代码:
private static IStoreEvents BuildEventStore(IBroker broker)
{
return Wireup.Init()
.UsingSqlPersistence(Constants.EventStoreConnectionStringName)
.InitializeStorageEngine()
.UsingJsonSerialization()
.Compress()
.UsingAsynchronousDispatchScheduler()
.DispatchTo(new DelegateMessageDispatcher(c => DispatchCommit(broker, c)))
.Build();
}
private static void DispatchCommit(IBroker broker, Commit commit)
{
foreach (var @event in commit.Events)
{
if(!(@event.Body is IDomainEvent))
{
throw new InvalidOperationException("An event was published that is not an IDomainEvent: " + @event.Body.GetType());
}
broker.Publish((IDomainEvent)@event.Body);
}
}