zoukankan      html  css  js  c++  java
  • eventFlow 系列 <一> 入门

    1 var exampleId = ExampleId.New;
    3 var commandBus = resolver.Resolve<ICommandBus>();
    4 var commond=new ExampleCommand(exampleId, 42,88) 5 var executionResult = await commandBus.PublishAsync(commond,CancellationToken.None) .ConfigureAwait(false); 6 var queryProcessor = resolver.Resolve<IQueryProcessor>(); var exampleReadModel = await queryProcessor.ProcessAsync( new ReadModelByIdQuery<ExampleReadModel>(exampleId),CancellationToken.None) .ConfigureAwait(false)

    这是最简单的测试。先是创建一个命令。创建命令没执行什么关键代码,命令有个身份,唯一标识,这个标识是exampleId

    commandBus发布这个命令,发布命令,主要是执行这个命令。这下面就是框架代码了。
     await ExecuteCommandAsync(command, cancellationToken).ConfigureAwait(false);

    这个方法中 AggregateStore.cs

    await _aggregateStore.UpdateAsync<TAggregate, TIdentity, TResult>
    var domainEvents = await aggregate.CommitAsync(
                            _eventStore,
                            _snapshotStore,
                            sourceId,
                            cancellationToken)
                            .ConfigureAwait(false);

    AggregateRoot.cs

    await eventStore.StoreAsync<TAggregate, TIdentity>()

    在这个方法中,会有选择保存在内存,SQLserver,Mongo中等地方。

    保存完了,以后使用的时候,读取文件或者数据库即可。


    这会找到这个命令的Controller.
    气功波(18037675651)
  • 相关阅读:
    阅读大道至简的读后感
    暑期第四周学习总结
    暑假学期第三周总结
    暑期学习第二周总结
    kuangbin专题 小希的迷宫
    Exam 5095 Hopscotch
    Exam 5431 //Barareh on Fire
    4.19 手写简单循环队列与栈
    web安全:xss && csrf
    web安全:HTTPS
  • 原文地址:https://www.cnblogs.com/qgbo/p/11577218.html
Copyright © 2011-2022 走看看