Azure Basic - Windows Storage Enhancement (Queue)
来源:互联网 发布:知乎首页的推送 编辑:程序博客网 时间:2024/06/05 08:15
Queue
- Get messages in a batch (In Sample 1)
- Poison message : use dequeuecount (In Sample 1)
- Delete message: always add try-catch at multiple consumers situation (In Sample 1)
- Always add time sleep to avoid "throttling" & "Money, Money, Money" (In Sample 1)
- Retry Policy (Microsoft.WindowsAzure.StorageClient.RetryPolicies)
- http://blogs.msdn.com/b/windowsazurestorage/archive/2011/02/03/overview-of-retry-policies-in-the-windows-azure-storage-client-library.aspx
- "
We strongly recommend using the exponential backoff retry policy provided by default whenever possible in order to gracefully backoff the load to your account, especially if throttling was to occur due to going over the scalability targets posted here. You can set this manually by via [Client].RetryPolicy = RetryPolicies.RetryExponential(RetryPolicies.DefaultClientRetryCount, RetryPolicies.DefaultClientBackoff).
Generally speaking a high throughput application that will be making simultaneous requests and can absorb infrequent delays without adversely impacting user experience are recommended to use the exponential backoff strategy detailed above. However for user facing scenarios such as websites and UI you may wish to use a linear backoff in order to maintain a responsive user experience.
Joe Giardino
"
- Always use partition key in the query
- Note: all messages will be encode using Base64
Sample 1
using System;using System.Collections.Generic;using System.Linq;using System.Text;using Microsoft.WindowsAzure;using Microsoft.WindowsAzure.StorageClient;using System.Threading;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { string accountName = "devstoreaccount1"; string key = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="; string containerName = "containername"; string blobName = "blobname"; StorageCredentialsAccountAndKey credentials = new StorageCredentialsAccountAndKey(accountName, key); string baseUri = string.Format("http://127.0.0.1:10001/{0}", accountName); CloudQueueClient queueStorage = new CloudQueueClient(baseUri, credentials); //Retry Policy queueStorage.RetryPolicy = RetryPolicies .RetryExponential(RetryPolicies.DefaultClientRetryCount, RetryPolicies.DefaultMaxBackoff); CloudQueue queue = queueStorage.GetQueueReference("guestthumbs"); queue.CreateIfNotExist(); for (int i = 0; i < 20; i++) { var message = new CloudQueueMessage(String.Format("{0},{1},{2}", i+":uniqueBlobName", "entry.PartitionKey", "entry.RowKey")); queue.AddMessage(message); Console.WriteLine("Input Message :" + message); } while (true) { IEnumerable<CloudQueueMessage> msgList = queue.GetMessages(32, TimeSpan.FromSeconds(20)); if (msgList == null) { //Time Sleep Thread.Sleep(TimeSpan.FromSeconds(5)); } else { try { foreach (CloudQueueMessage msg in msgList) { if (msg.DequeueCount < 8) { Console.WriteLine("Output Message : "+msg.AsString); } else { //Handle Poison Message } queue.DeleteMessage(msg); } } catch (StorageClientException ex) { if (ex.ExtendedErrorInformation.ErrorCode == "MessageNotFound") { // pop receipt must be invalid // ignore or log (so we can tune the visibility timeout) } else { // not the error we were expecting throw; } } } } } }}
- Azure Basic - Windows Storage Enhancement (Queue)
- Azure Basic - Windows Storage Enhancement (Blob)
- Azure Basic - Windows Storage Enhancement (Table)
- Windows Azure 之 Storage Queue常用操作
- Azure Basic - Insert data into BlockBlob, Table and Queue (with Diagnostic + Azure Storage Explore)
- Windows Azure入门教学系列 (五):使用Queue Storage
- Azure Queue Storage 基本用法 -- Azure Storage 之 Queue
- Windows Azure Storage浏览器
- Windows Azure Storage
- Windows Azure(四-3):云上的MSMQ--Queue Storage
- Windows Azure Introduction - Storage: Blob
- 公布Windows Azure Storage Analytics
- Windows Azure Storage Analytics Features
- Windows Azure 系列-- Azure Queue的操作
- Windows Azure Platform (九) Windows Azure Storage Service存储服务
- 云计算存储Windows Azure Storage 随笔
- 使用Windows Azure Storage Analytics新特性
- Windows Azure 之 Storage Blob 常见操作
- ubuntu默认防火墙
- 软件快捷键失灵及解决办法解决
- 通往WinDbg的捷径
- U_boot 的 bootcmd 和bootargs参数详解
- 通过NSInputStream读取大文件的指定起始内容
- Azure Basic - Windows Storage Enhancement (Queue)
- sicily 1036
- 面试考官想得到什么
- test 22222
- Android Widget 电池插件的开发实现 .
- 使用__FILE__和__LINE__定位错误
- 那些让 Web 开发者们深感意外的事情
- 击毙拉登行动之白宫指挥现场
- 传Facebook最快下月提交IPO申请文件