Example #1
0
        public static List <CloudQueueMessage> GetQueueMessages(QueueTypeEnum type, int messageCount)
        {
            messageCount = Math.Min(messageCount, 32); //32 is hard limit
            CloudQueue queue = GetCloudQueue(type);

            List <CloudQueueMessage> queueMessageList = new List <CloudQueueMessage>();

            IEnumerable <CloudQueueMessage> queueMessages = queue.GetMessages(messageCount);

            if ((queueMessages != null) && (queueMessages.Count <CloudQueueMessage>() > 0))
            {
                foreach (CloudQueueMessage message in queueMessages)
                {
                    //Check Poisen Message
                    if (message.DequeueCount < 3)
                    {
                        queueMessageList.Add(message);
                    }
                    else
                    {
                        AddQueueMessage(QueueTypeEnum.FailuresTwitter, message.AsString);
                        queue.DeleteMessage(message);
                    }
                }
            }

            return(queueMessageList);
        }
Example #2
0
        public static CloudQueueMessage GetQueueMessage(QueueTypeEnum type)
        {
            CloudQueue        queue = GetCloudQueue(type);
            CloudQueueMessage message;

            bool loop = true;

            do
            {
                message = queue.GetMessage();
                if (message == null)
                {
                    loop = false; //No Message
                }
                else if (message.DequeueCount < 3)
                {
                    loop = false; //Good Message
                }
                else
                {
                    //Poisen Message
                    AddQueueMessage(QueueTypeEnum.FailuresTwitter, message.AsString);
                    queue.DeleteMessage(message);
                }
            } while (loop);

            return(message);
        }
Example #3
0
        public static CloudQueue GetCloudQueue(QueueTypeEnum type)
        {
            //Queue eference Format
            string queueReference = type.ToString().ToLower();

            CloudQueueClient queueClient = GetStorageAccount().CreateCloudQueueClient();
            CloudQueue       queue       = queueClient.GetQueueReference(queueReference);

            queue.CreateIfNotExist();
            return(queue);
        }
Example #4
0
        public CollectionsOfficer(string station, string collector, QueueTypeEnum collectionsQueue)
        {
            _station          = station;
            _collector        = collector;
            _collectionsQueue = collectionsQueue;
            _loopOfficer      = true;
            _currentTask      = new CollectionsTask();
            _currentTask.Id   = "NO ID"; //placeholder for no new task
#if DEBUG
            //Sleep for 1 Minute
            _sleepOfficer = 60000;
#else
            //Sleep for 20 Minutes
            _sleepOfficer = 1200000;
#endif
            worker                            = new BackgroundWorker();
            worker.DoWork                    += worker_DoWork;
            worker.RunWorkerCompleted        += worker_RunWorkerCompleted;
            worker.WorkerSupportsCancellation = true;
        }
Example #5
0
        public static void AddQueueMessage(QueueTypeEnum type, string message)
        {
            CloudQueue queue = GetCloudQueue(type);

            queue.AddMessage(new CloudQueueMessage(message));
        }
Example #6
0
        public static string GetQueuesStatus(QueueTypeEnum type)
        {
            CloudQueue queue = GetCloudQueue(type);

            return(string.Format("{0} queue #{1} messages.", queue.Name, queue.RetrieveApproximateMessageCount()));
        }
Example #7
0
        public static void DeleteQueueMessage(QueueTypeEnum type, CloudQueueMessage message)
        {
            CloudQueue queue = GetCloudQueue(type);

            queue.DeleteMessage(message);
        }