Exemplo n.º 1
0
        public static void LogQueuePoller(object state)
        {
            Trace.WriteLine("LogPoller has started -- seeing if there's anything in the queue for me!!");

            CloudQueueMessage msg = LogQueue.GetMessage();

            if (msg == null)
            {
                Trace.TraceInformation("LOG QUEUE nothing found - going back to sleep");
            }

            while (msg != null)
            {
                //do something
                string myMessage = msg.AsString;
                LogQueue.DeleteMessage(msg);
                Trace.TraceInformation("Got message {0}", myMessage);

                CloudBlockBlob theBlob = LogBlobContainer.GetBlockBlobReference(myMessage);
                AgileWays.Cqrs.Commands.Logging.LogCommand theLog;

                DeserializeObjectFromBlob <AgileWays.Cqrs.Commands.Logging.LogCommand>(theBlob, out theLog);

                if (theLog != null)
                {
                    WriteLogToStorage(myMessage, theLog);
                }
                else
                {
                    Trace.TraceInformation("Could not deserialize message from queue id {0}", myMessage);
                }

                msg = LogQueue.GetMessage();
            }
        }