Пример #1
0
        public async void PublisherNewOrder()
        {
            if (_lastTask != null && !_lastTask.IsCompleted)
            {
                return;
            }

            var config      = _configuration.GetSection("serviceBus").Get <ServiceBusConfiguration>();
            var topicClient = new TopicClient(config.ConnectionString, Topic);

            var order = new OrderChangedMessage
            {
                OrderId = Guid.NewGuid(),
                StoreId = Guid.Parse(StoreId),
                State   = (GeekBurger.Orders.Contract.Enums.OrderState) new Random().Next(1, 3)
            };

            _lastTask = SendMessagesAsync(topicClient, GetMessage(order));

            _orderChanged.PublisherStartNewOrder(order);

            await _lastTask;

            var   closeTask = topicClient.CloseAsync();
            await closeTask;

            HandleException(closeTask);
        }
 public IActionResult PublisherTopicStartNewOrders([FromBody] OrderChangedMessage order)
 {
     _orderChanged.PublisherStartNewOrder(order);
     return(Ok());
 }