Опубликован: 30.05.2011 | Уровень: специалист | Доступ: платный
Самостоятельная работа 7:
Работа с Windows AzureQueue
Список вспомогательных материалов
Работа с Windows Azure Queue
- http://msdn.microsoft.com/en-us/wazplatformtrainingcourse_exploringwindowsazurestoragevs2010_topic4
- http://dotnetbyexample.blogspot.com/2009/07/storing-objects-as-compressed-messages.html
- http://soumya.wordpress.com/2010/05/20/azure-simplified-part-4-using-azure-queue-storage/
- http://www.dotnetconsult.co.uk/weblog2/PermaLink,guid,c24f8177-f6bf-479b-bd5c-d532e0e40272.aspx
Приложение А AzureQueueSample.aspx.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.StorageClient; using Microsoft.WindowsAzure.ServiceRuntime; namespace WebRole1 { public partial class AzureQueueSample : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btn_send_Click(object sender, EventArgs e) { var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); var queueClient = storageAccount.CreateCloudQueueClient(); var queue = queueClient.GetQueueReference("messagequeue"); queue.CreateIfNotExist(); var msg = new CloudQueueMessage(tb_message.Text); queue.AddMessage(msg); tb_message.Text = string.Empty; } } }
Приложение Б Global.asax.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Security; using System.Web.SessionState; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.ServiceRuntime; namespace WebRole1 { public class Global : System.Web.HttpApplication { void Application_Start(object sender, EventArgs e) { CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) => { configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)); }); } void Application_End(object sender, EventArgs e) { } void Application_Error(object sender, EventArgs e) { } void Session_Start(object sender, EventArgs e) { } void Session_End(object sender, EventArgs e) { } } }