/// <summary> /// Returns the next available task pending on the "Notification" Azure queue. /// </summary> /// <returns>A task instance which may be null if the queue is currently empty.</returns> /// <remarks> /// This method attempts to read the message at the top of the Azure queue. If a /// message is present, it is converted to an appropriate ITask instance. If the /// conversion fails or the queue is empty, a null value is returned. /// </remarks> public ITask NextTaskFromNotificationQueue() { ITask task = null; try { // CloudQueue queue = Storage.UpdateRequestsQueue; IQueueRepository queueRepository = DependencyResolver.Current.GetService(typeof(IQueueRepository)) as IQueueRepository; CloudQueue queue = queueRepository.NotificationQueue; CloudQueueMessage msg = queue.GetMessage(); if (msg != null) { Logger.Logger.Info("Got message from notifications queue."); queue.DeleteMessage(msg); object request = queueRepository.Unpack(msg); if (Constants.SendMultipleMails) { Logger.Logger.Verbose("Creating MultipleEmailTask."); task = new MultipleEmailTask(request); return(task); } else { Logger.Logger.Verbose("Creating EmailTask."); task = new EmailTask(request); return(task); } } } catch (Exception ex) { Logger.Logger.Error(ex, "Failed to read a message from notifications queue."); } return(task); }
/// <summary> /// Returns the next available task pending on the "Notification" Azure queue. /// </summary> /// <returns>A task instance which may be null if the queue is currently empty.</returns> /// <remarks> /// This method attempts to read the message at the top of the Azure queue. If a /// message is present, it is converted to an appropriate ITask instance. If the /// conversion fails or the queue is empty, a null value is returned. /// </remarks> public ITask NextTaskFromNotificationQueue() { ITask task = null; try { // CloudQueue queue = Storage.UpdateRequestsQueue; IQueueRepository queueRepository = DependencyResolver.Current.GetService(typeof(IQueueRepository)) as IQueueRepository; CloudQueue queue = queueRepository.NotificationQueue; CloudQueueMessage msg = queue.GetMessage(); if (msg != null) { Logger.Logger.Info("Got message from notifications queue."); queue.DeleteMessage(msg); object request = queueRepository.Unpack(msg); if (Constants.SendMultipleMails) { Logger.Logger.Verbose("Creating MultipleEmailTask."); task = new MultipleEmailTask(request); return task; } else { Logger.Logger.Verbose("Creating EmailTask."); task = new EmailTask(request); return task; } } } catch (Exception ex) { Logger.Logger.Error(ex, "Failed to read a message from notifications queue."); } return task; }