Пример #1
0
        public async Task Handle(MyStartSagaCommand message, IMessageHandlerContext context)
        {
            MyTimer.Start();
            Data.Data = message.Data;
            await Console.Out.WriteLineAsync($"[{Data.MyEntityId}] Saga has been started: {Data.Data}");

            await context.SendLocal(new MyRequestMessage()
            {
                MyEntityId = Data.MyEntityId
            });
        }
Пример #2
0
        private async Task IfDoneReplyAndMarkComplete(IMessageHandlerContext context)
        {
            if (!AllTasksComplete())
            {
                return;
            }

            MyTimer.Stop();

            await Console.Out.WriteLineAsync($"[{Data.MyEntityId}] Saga complete. Sending response...");

            await Console.Out.WriteLineAsync($"[{Data.MyEntityId}] Saga duration: {MyTimer.ElapsedMilliseconds()}ms");

            await ReplyToOriginator(context,
                                    new MySagaResponse()
            {
                Data = Data.MyEntityId.ToString(), MyEntityId = Data.MyEntityId
            })
            .ConfigureAwait(false);

            MarkAsComplete();
        }