Пример #1
0
        public async Task Handle(DocumentSagaStartCmd message, IMessageHandlerContext context)
        {
            _logger.Info($"{message.CorrelationId} - DocumentSaga.StartCmd.Handle Start - {JsonConvert.SerializeObject(message)}");

            Data.SagaStartTimeUtc = DateTime.UtcNow;
            Data.EventId          = message.EventId;
            Data.ResourceId       = message.ResourceId;
            Data.InstanceId       = message.InstanceId;
            Data.RowId            = message.Id;
            Data.EnqueueDtTm      = message.EnqueueDtTm;
            Data.PickupDtTm       = message.PickupDtTm;
            Data.CorrelationId    = message.CorrelationId;
            Data.StatusId         = message.StatusId;
            Data.ThrottleId       = message.ThrottleId;
            Data.WorkerId         = message.WorkerId;

            // need to send message to document worker
            var documentEvent = message.ToDocumentWorkerEvent();

            if (!Data.IsEventDispatchedToDocumentWorkerBit)
            {
                await context.Publish(documentEvent).ConfigureAwait(false);

                Data.IsEventDispatchedToDocumentWorkerBit = true;
            }

            _logger.Info($"{message.CorrelationId} - DocumentSaga.StartCmd.Handle RequestTimeout {nameof(ConstantValue.DefaultSagaTimeoutInSeconds)} with values {ConstantValue.DefaultSagaTimeoutInSeconds}");
            await RequestTimeout <DocumentTimeout>(context, TimeSpan.FromSeconds(ConstantValue.DefaultSagaTimeoutInSeconds)).ConfigureAwait(false);

            _logger.Info($"{message.CorrelationId} - DocumentSaga.StartCmd.Handle End");
        }
 public static DocumentWorkerEvent ToDocumentWorkerEvent(this DocumentSagaStartCmd documentStartCmd)
 {
     return(new DocumentWorkerEvent
     {
         CmdId = documentStartCmd.CmdId,
         CorrelationId = documentStartCmd.CorrelationId,
         EventId = documentStartCmd.EventId,
         Id = documentStartCmd.Id,
         InstanceId = documentStartCmd.InstanceId,
         ResourceId = documentStartCmd.ResourceId,
         StatusId = documentStartCmd.StatusId
     });
 }