示例#1
0
        public Task Handle(GoodsNotInStockEvent message, IMessageHandlerContext context)
        {
            //TODO: acutal business logic goes here
            //TODO: compensate and inform customer

            log.Info($"Goods are not in stock for CartId {message.CartId}");
            MarkAsComplete();
            return(Task.CompletedTask);
        }
示例#2
0
        public Task Handle(CheckGoodsInStockCommand message, IMessageHandlerContext context)
        {
            //TODO: actual business logic goes here

            //randomly return negative events
            if (random.Next(0, 5) == 0)
            {
                var goodsNotInStock = new GoodsNotInStockEvent
                {
                    CartId = message.CartId
                };
                return(context.Publish(goodsNotInStock));
            }

            var goodsInStock = new GoodsInStockEvent
            {
                CartId = message.CartId
            };

            return(context.Publish(goodsInStock));
        }