Azure Basic - Windows Storage Enhancement (Queue)
2011-11-20 00:25
501 查看
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
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; } } } } } } }
相关文章推荐
- Windows Azure Cloud Service (12) PaaS之Web Role, Worker Role, Azure Storage Queue(下)
- Windows Azure Platform (二十六) Windows Azure Storage之Table、Queue
- 怎么使用Windows Azure Queue Storage 服务
- 利用Windows Azure Queue Storage给AutoCAD传递对象
- [Windows Azure] Windows Azure Storage & SQL Database
- Windows Azure Storage (5) Windows Azure Drive
- Windows Azure Storage Emulator 无法安装和无法启动问题
- Azure Basic - Windows Storage Enhancement (Blob)
- 【FWD】Windows Azure Table Storage vs. Windows SQL Azure
- Windows Azure Storage – 4万亿对象和计数
- 使用Windows Azure Storage Analytics新特性
- 云计算和数据 关于Windows Azure Table Storage 和 SQL Azure的选择
- Overview of Retry Policies in the Windows Azure Storage Client Library
- Windows Azure Storage (2) Windows Azure Storage Service存储服务之Blob详解(上)
- Windows Azure Storage (4) Windows Azure Storage Service存储服务之Blob Share Access Signature
- Troubleshooting - Windows Azure Storage Emulator Cannot Start
- C# Windows Azure Queue的操作
- Windows Azure Storage (18) 使用HTML5 Portal的Azure CDN服务
- 通过构建Storage Explorer 应用学习Windows Azure Storage APIs
- Azure Basic - Windows Storage Enhancement (Table)