Пример #1
0
        /// <summary>
        /// Grab the queue message and delete it
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="queueName"></param>
        /// <param name="operation"></param>
        /// <returns></returns>
        public static bool ExecuteAlertOperation <T>(string queueName, Action <T> operation)
        {
            CloudQueueMessage queueMsg = null;

            if (queueRepo.GetMessage(queueName, out queueMsg))
            {
                if (queueMsg.DequeueCount < 3) //-- Try process twice and then just delete the message
                {
                    LastQueueMessage.MessageAsString = string.Format("Dequeue[{0}] {1}", queueMsg.DequeueCount, queueMsg.AsString);
                    var dto = new JavaScriptSerializer().Deserialize <T>(queueMsg.AsString);
                    operation(dto);
                }
                queueRepo.DeleteMessage(queueName, queueMsg);
                return(true);
            }

            return(false);
        }