Exemplo n.º 1
0
        public static Task Send <TMessage>(this IBrokeredMessageDispatcher dispatcher,
                                           TMessage message,
                                           RoutingSlip slip,
                                           TransactionContext transactionContext = null,
                                           SendOptions options = null)
            where TMessage : ICommand
        {
            if (options == null)
            {
                options = new SendOptions();
            }

            var destination = slip.RouteToNextStep();

            options.WithRoutingSlip(slip);

            return(dispatcher.Send(message, destination, transactionContext, options));
        }
Exemplo n.º 2
0
        public async Task Start <TSagaMessage>(TSagaMessage message, IMessageHandlerContext context)
            where TSagaMessage : ISagaMessage
        {
            SagaContext saga = await _sagaInitializer.Initialize(message, context).ConfigureAwait(false);

            var options = _sagaOptionsProvider.GetOptionsFor(message);

            var sendOptions = new SendOptions()
                              .WithSubject(options.Description)
                              .WithTimeToLiveInMinutes(options.MaxSagaDurationInMinutes)
                              .WithTransactionMode(options.TransactionMode)
                              .WithSagaId(saga.SagaId)
                              .WithSagaStatus(saga.Status.Status);

            await _brokeredMessageDispatcher.Send(message, options : sendOptions).ConfigureAwait(false);

            saga.InProgress();

            await _sagaPersister.Persist(saga, message, context).ConfigureAwait(false);
        }