public static async Task Execute(this IBus bus, RoutingSlip routingSlip)
        {
            if (routingSlip.RanToCompletion())
            {
                DateTime timestamp = DateTime.UtcNow;
                TimeSpan duration  = timestamp - routingSlip.CreateTimestamp;

                IRoutingSlipEventPublisher publisher = new RoutingSlipEventPublisher(bus, routingSlip);

                await publisher.PublishRoutingSlipCompleted(timestamp, duration, routingSlip.Variables);
            }
            else
            {
                ISendEndpoint endpoint = await bus.GetSendEndpoint(routingSlip.GetNextExecuteAddress());

                await endpoint.Send(routingSlip, Pipe.New <SendContext>(x => x.UseExecute(context => context.SourceAddress = bus.Address)));
            }
        }
Пример #2
0
        public static async Task Execute <T>(this T source, RoutingSlip routingSlip)
            where T : IPublishEndpoint, ISendEndpointProvider
        {
            if (routingSlip.RanToCompletion())
            {
                var timestamp = DateTime.UtcNow;
                var duration  = timestamp - routingSlip.CreateTimestamp;

                IRoutingSlipEventPublisher publisher = new RoutingSlipEventPublisher(source, source, routingSlip);

                await publisher.PublishRoutingSlipCompleted(timestamp, duration, routingSlip.Variables);
            }
            else
            {
                var endpoint = await source.GetSendEndpoint(routingSlip.GetNextExecuteAddress());

                await endpoint.Send(routingSlip);
            }
        }