Esempio n. 1
0
        private async Task NotifyTopic(string topicName, object @event)
        {
            var client = TopicClient.CreateFromConnectionString(this.serviceBusConfiguration.ConnectionString, this.serviceBusConfiguration.OrderCreatedTopicName);
            var msg    = BrokeredMessageFactory.CreateJsonMessage(@event);

            await client.SendAsync(msg);
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([FromBody] CreateOrderCommand command)
        {
            if (command == null)
            {
                return(this.BadRequest("Invalid commmand, ensure body has json payload"));
            }

            if (command.OrderId == Guid.Empty)
            {
                command.OrderId = Guid.NewGuid();
            }

            var queueClient = QueueClient.CreateFromConnectionString(this.serviceBusConfiguration.ConnectionString, this.serviceBusConfiguration.CreateOrderQueueName);
            await queueClient.SendAsync(BrokeredMessageFactory.CreateJsonMessage(command));

            return(CreatedAtAction(nameof(Get), new { orderId = command.OrderId }, command.OrderId));
        }
Esempio n. 3
0
 private async Task RaiseEvent(string productChangedTopicName, ProductChangedEvent productChangedEvent)
 {
     var topicClient = TopicClient.CreateFromConnectionString(this.serviceBusConfiguration.ConnectionString, this.serviceBusConfiguration.ProductChangedTopicName);
     await topicClient.SendAsync(BrokeredMessageFactory.CreateJsonMessage(productChangedEvent));
 }
Esempio n. 4
0
 private async Task SendCommand(string queueName, object command)
 {
     var queueClient = QueueClient.CreateFromConnectionString(this.serviceBusConfiguration.ConnectionString, queueName);
     await queueClient.SendAsync(BrokeredMessageFactory.CreateJsonMessage(command));
 }