Skip to content

Retrieving messages

Vivek Maurya edited this page Nov 17, 2022 · 1 revision

Retrieving messages from storage queue

Here we are trying to retrieve messages using azure functions

as soon as a message is sent to the queue the function gets triggered and message is retrieved

 public class ProcessOrder
    {
        private readonly IOrder _order;
        private readonly ILogger<ProcessOrder> _logger;

        public ProcessOrder(IOrder order, ILogger<ProcessOrder> logger)
        {
           _order = order;
           _logger = logger;
        }
        [FunctionName("ProcessOrder")]
        public void Run([QueueTrigger("order-queue", Connection = "OrderQueueConnection")]string message)
        {
              _logger.LogInformation($"C# Queue trigger function processed: {message}");
            var order = JsonSerializer.Deserialize<Order>(message);
            _order.ExecuteOrder(order);
        }
    }