Example #1
0
        /// <summary>
        /// Called when a new order is sent. Validates the order and registers for when
        /// it's triggered.
        /// </summary>
        /// <param name="order">The information about the order that was sent.</param>
        private void OnOrderSent(OrderInfo order)
        {
            ValidateOrder(order);

            if (!validatedOrders.Contains(order))
            {
                validatedOrders = validatedOrders.Add(order);
                OrderValidated.SafeTrigger(order);
            }

            CheckIfOrderTriggered(order);
        }
Example #2
0
    public Task Handle(ValidateOrder message, IMessageHandlerContext context)
    {
        var validated = new OrderValidated
        {
            OrderId = message.OrderId,
            Sender  = message.Sender
        };

        log.Info($"Validating order {message.OrderId}. It will take 3 seconds.");

        var options = new SendOptions();

        options.RouteToThisEndpoint();
        options.DelayDeliveryWith(TimeSpan.FromSeconds(3));
        return(context.Send(validated, options));
    }