示例#1
0
        public async Task Consume(ConsumeContext <IOrder> context)
        {
            var order = context.Message;

            if (order.StatusKey != EventConstants.EVENT_STATUS_KEY_STORAGE)
            {
                // 如果不是StorageService要处理的Event则忽略该消息
                return;
            }

            var result = StorageRepository.CreateStorage(order).GetAwaiter().GetResult();

            if (result)
            {
                IOrderEventEntity orderEventEntity = new OrderEventEntity
                {
                    OrderID     = order.ID,
                    EventType   = EventConstants.EVENT_TYPE_CREATE_ORDER,
                    StatusKey   = EventConstants.EVENT_STATUS_KEY_STORAGE,
                    StatusValue = EventStatusEnum.HANDLED
                };

                await EventBus.Publish(orderEventEntity);
            }
        }