Esempio n. 1
0
        //Poison Message
        public void ProcessMessage()
        {
            CloudQueueClient queueClient      = StorageClientManager.GetQueueClient();
            CloudQueue       collectionsQueue = queueClient.GetQueueReference(_queueCollections);

            collectionsQueue.CreateIfNotExist();

            CloudQueueMessage message = collectionsQueue.GetMessage();

            if (message == null)
            {
                //Stop Polling
                return;
            }

            try
            {
                //Do Work
                collectionsQueue.DeleteMessage(message);
            }
            catch //Handle Poisned Messages
            {
                if (message.DequeueCount > 3)
                {
                    CloudQueue poisonQueue = queueClient.GetQueueReference(_queuePoison);
                    poisonQueue.CreateIfNotExist();
                    poisonQueue.AddMessage(message);
                    collectionsQueue.DeleteMessage(message);
                }
            }
        }
Esempio n. 2
0
        public void RunQueues()
        {
            Console.WriteLine("RunQueues()");
            _queueClient = StorageClientManager.GetQueueClient();

            CreateQueue(_queueName);
            GetQueueInfomration(_queueName);
            DeleteQueue(_queueName);
        }
Esempio n. 3
0
        //Create 1,000 Queues
        private void CreateJobs()
        {
            CloudQueueClient queueClient = StorageClientManager.GetQueueClient();

            queueClient.GetQueueReference(_queueCollections);
            CloudQueue queue = queueClient.GetQueueReference(_queueCollections);

            for (int i = 0; i < 10000; i++)
            {
                CloudQueueMessage message = new CloudQueueMessage(string.Format("collection job #{0}", i));
                queue.AddMessage(message);
            }
        }
Esempio n. 4
0
        public void RunBlobs()
        {
            Console.WriteLine("RunBlobs()");

            //Blob Client
            CloudBlobClient blobClient = StorageClientManager.GetBlobClient();

            //Get Container
            CloudBlobContainer blobContainer = blobClient.GetContainerReference(_blobContainerName);

            blobContainer.CreateIfNotExist();

            //Create Text
            StringBuilder sb   = new StringBuilder("Howdy World!");
            CloudBlob     blob = blobContainer.GetBlobReference(_blobName);

            blob.Attributes.Metadata["Status"] = "Unprocessed";
            blob.UploadText(sb.ToString());

            blob.FetchAttributes();
            Console.WriteLine("MD5 = " + blob.Attributes.Properties.ContentMD5);
            foreach (string key in blob.Attributes.Metadata)
            {
                Console.WriteLine(string.Format("Key={0}, Value={1}", key, blob.Attributes.Metadata[key]));
            }

            //List Blobs
            foreach (var blobItem in blobContainer.ListBlobs())
            {
                Console.WriteLine(blobItem.Uri.ToString());
            }

            //Print Blob
            CloudBlob blob2  = blobContainer.GetBlobReference(_blobName);
            string    output = blob2.DownloadText();

            //string output = blockBlob.DownloadText();
            Console.WriteLine(String.Format("{0} says, {1}", _blobName, output));

            //Delete Blob
            blob2.DeleteIfExists();

            //List Blobs
            Console.WriteLine("List Blobs:");
            foreach (var blobItem in blobContainer.ListBlobs())
            {
                Console.WriteLine(blobItem.Uri.ToString());
            }
        }
Esempio n. 5
0
        public void RunTables()
        {
            Console.WriteLine("RunTables()");
            CloudTableClient tableClient = StorageClientManager.GetTableClient();

            //Create Table
            tableClient.CreateTableIfNotExist(_tableName);

            //List Tables
            IEnumerable <string> tables = tableClient.ListTables();

            foreach (string table in tables)
            {
                Console.WriteLine(table);
            }

            //DataModel, DataContext



            tableClient.DeleteTableIfExist(_tableName);
        }