Пример #1
0
        public Task Timeout(FedexAndDhlFailed state, IMessageHandlerContext context)
        {
            Console.WriteLine("Timeout for message FedexAndDhlFailed orderId: {0} OrderNumber: {1}", Data.OrderId,
                              Data.OrderNumber);

            if (Data.FedexFailed && Data.DhlFailed)
            {
                // try again
                Data.FedexFailed = false;
                var customerNumber = new Guid("f64bb7b3-fb1c-486e-b745-8062bf30e4d3");

                // do some shipping related logic
                var dispatchOrderToDhl = new DispatchOrderToDhl
                {
                    CountryCode       = Data.CountryCode,
                    OrderId           = Data.OrderId,
                    DhlCustomerNumber = customerNumber,
                    DispatchId        = Guid.NewGuid(),
                    ThrowException    = Data.ThrowException
                };

                //Dispatch the order to DHL
                Console.WriteLine($"OrderId {Data.OrderId} resent to DHL after timeout");
                return(context.Send(dispatchOrderToDhl));
            }

            Console.WriteLine($"OrderId {Data.OrderId} done after timeout");
            return(Task.CompletedTask);
        }
        public async Task Handle(FedexAndDhlFailed message, IMessageHandlerContext context)
        {
            // do stuff?
            var customerNumber = new Guid("f64bb7b3-fb1c-486e-b745-8062bf30e4d3");

            Console.WriteLine("Handling message FedexAndDhlFailed orderId: {0} OrderNumber: {1}", Data.OrderId,
                              Data.OrderNumber);

            // do some shipping related logic
            var dispatchOrderToDhl = new DispatchOrderToDhl
            {
                CountryCode       = Data.CountryCode,
                OrderId           = Data.OrderId,
                DhlCustomerNumber = customerNumber,
                DispatchId        = Guid.NewGuid(),
                ThrowException    = Data.ThrowException
            };

            //Dispatch the order to DHL
            await context.Send(dispatchOrderToDhl).ConfigureAwait(false);
        }