• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Queue.CloudQueueMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Queue.CloudQueueMessage的典型用法代码示例。如果您正苦于以下问题:C# CloudQueueMessage类的具体用法?C# CloudQueueMessage怎么用?C# CloudQueueMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CloudQueueMessage类属于Microsoft.WindowsAzure.Storage.Queue命名空间,在下文中一共展示了CloudQueueMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
            var queueClient = storageAccount.CreateCloudQueueClient();

            var queue = queueClient.GetQueueReference("samples-asq-nativeintegration"); //"Samples.ASQ.NativeIntegration");

            #region SerializedMessage

            var nativeMessage = @"{""Content"":""Hello from native sender"",""SendOnUtc"":""2015-10-27T20:47:27.4682716Z""}";
            var nativeMessageAsBytes = Encoding.UTF8.GetBytes(nativeMessage);

            #endregion

            #region NecessaryHeaders

            var headers = new Dictionary<string, string>
            {
                { "NServiceBus.EnclosedMessageTypes", "Shared.NativeMessage" },
                { "NServiceBus.MessageIntent", "Send" }
            };

            #endregion
            // TODO: message body is byte
            var message = new CloudQueueMessage(@"{""IdForCorrelation"":null,""Id"":""31949487-2b67-49e0-b961-96f7a834d877"",""MessageIntent"":1,""ReplyToAddress"":""native-sender"",""TimeToBeReceived"":""00:00:00"",""Headers"":{""NServiceBus.EnclosedMessageTypes"":""Shared.NativeMessage"",""NServiceBus.MessageIntent"":""Send""},""Body"":""eyJDb250ZW50IjoiSGVsbG8gZnJvbSBuYXRpdmUgc2VuZGVyIiwiU2VuZE9uVXRjIjoiMjAxNS0xMC0yOFQwNDowNDo0MC45MDg0NDI4WiJ9"",""CorrelationId"":null,""Recoverable"":false}");
            queue.AddMessage(message);

            Console.WriteLine("Native message sent");
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
开发者ID:SeanFeldman,项目名称:NSB.ASQ.NativeSender,代码行数:31,代码来源:Program.cs


示例2: crawlingPhase

        public void crawlingPhase(CloudQueueMessage urlMessage)
        {
            totalUrls++;
            String url = urlMessage.AsString;
            if (!alreadyVisitedUrls.Contains(url))
            {
                alreadyVisitedUrls.Add(url);
                try
                {
                    HtmlWeb hw = new HtmlWeb();
                    HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                    doc = hw.Load(url);
                    String date = "";
                    if (doc.DocumentNode.SelectSingleNode("//head/meta[@property='og:pubdate']") != null)
                    {
                        String stringDate = doc.DocumentNode.SelectSingleNode("//head/meta[@property='og:pubdate']").GetAttributeValue("content", "default").Substring(0, 10);
                        date = DateTime.ParseExact(stringDate, "yyyy-MM-dd", CultureInfo.InvariantCulture).ToString("yyyy/MM/dd");
                    }
                    String fullTitle = doc.DocumentNode.SelectSingleNode("//head/title").InnerText;
                    String[] titles = fullTitle.Split(' ');
                    foreach (string partTitle in titles) {
                        if (!partTitle.Equals(" ") && !partTitle.Equals("-") && !partTitle.Equals("CNN.com") && !partTitle.Equals(""))
                        {
                            CrawlerEntry entry = new CrawlerEntry(url, fullTitle, date, partTitle);
                            TableOperation insertOperation = TableOperation.Insert(entry);
                            table.Execute(insertOperation);
                            tableSize++;
                        }
                    }

                    //get urls in page
                    foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
                    {
                        string href = link.GetAttributeValue("href", string.Empty);
                        HashSet<String> links = new HashSet<String>();
                        String[] hrefSplit = href.Split('/');
                        String html = hrefSplit[hrefSplit.Length - 1];
                        //if the href is not in the disallowed urls, is not already crawled, is not a duplicate link, is a valid html page, and on cnn or bleacherreport
                        if (!disallowedUrls.Any(s => href.Contains(s)) && !alreadyVisitedUrls.Any(s => s.Equals(href)) && !links.Contains(href) && rgx.IsMatch(html) && (href.Contains("cnn.com") || href.Contains("bleacherreport.com")))
                        {
                            //store remaining into queue
                            urlQueue.AddMessage(new CloudQueueMessage(href));

                            //adds link to current link set
                            links.Add(href);
                        }
                    }
                }
                catch
                {

                }
            }

            updateTotalUrls();
            //Update last 10 urls crawled
            updateLastUrl(urlMessage.AsString);

            urlQueue.DeleteMessage(urlMessage);
        }
开发者ID:kinderst,项目名称:Web-Service-Like-Google,代码行数:60,代码来源:Crawler.cs


示例3: CreateCloudQueueMessageFromByteArray

        public static CloudQueueMessage CreateCloudQueueMessageFromByteArray([ReadOnlyArray] byte[] content)
#endif
        {
            CloudQueueMessage message = new CloudQueueMessage(null);
            message.SetMessageContent(content);
            return message;
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:7,代码来源:CloudQueueMessage.cs


示例4: AQ_Standalone_1

        public async Task AQ_Standalone_1()
        {
            queueName = "Test-1-".ToLower() + Guid.NewGuid();
            AzureQueueDataManager manager = await GetTableManager(queueName);
            Assert.AreEqual(0, await manager.GetApproximateMessageCount());

            CloudQueueMessage inMessage = new CloudQueueMessage("Hello, World");
            await manager.AddQueueMessage(inMessage);
            //Nullable<int> count = manager.ApproximateMessageCount;
            Assert.AreEqual(1, await manager.GetApproximateMessageCount());

            CloudQueueMessage outMessage1 = await manager.PeekQueueMessage();
            logger.Info("PeekQueueMessage 1: {0}", AzureStorageUtils.PrintCloudQueueMessage(outMessage1));
            Assert.AreEqual(inMessage.AsString, outMessage1.AsString);

            CloudQueueMessage outMessage2 = await manager.PeekQueueMessage();
            logger.Info("PeekQueueMessage 2: {0}", AzureStorageUtils.PrintCloudQueueMessage(outMessage2));
            Assert.AreEqual(inMessage.AsString, outMessage2.AsString);

            CloudQueueMessage outMessage3 = await manager.GetQueueMessage();
            logger.Info("GetQueueMessage 3: {0}", AzureStorageUtils.PrintCloudQueueMessage(outMessage3));
            Assert.AreEqual(inMessage.AsString, outMessage3.AsString);
            Assert.AreEqual(1, await manager.GetApproximateMessageCount());

            CloudQueueMessage outMessage4 = await manager.GetQueueMessage();
            Assert.IsNull(outMessage4);

            Assert.AreEqual(1, await manager.GetApproximateMessageCount());

            await manager.DeleteQueueMessage(outMessage3);
            Assert.AreEqual(0, await manager.GetApproximateMessageCount());
        }
开发者ID:stanroze,项目名称:orleans,代码行数:32,代码来源:AzureQueueDataManagerTests.cs


示例5: AddQuere

 public async Task AddQuere(RImage img)
 {
     CloudQueue queue = QueueClient.GetQueueReference("myqueues");
     await queue.CreateIfNotExistsAsync();
     CloudQueueMessage message = new CloudQueueMessage(JsonConvert.SerializeObject(img));
     await queue.AddMessageAsync(message);
 }
开发者ID:peacecwz,项目名称:AAYazOkuluCloudService,代码行数:7,代码来源:BlobManager.cs


示例6: SignButton_Click

        protected void SignButton_Click(object sender, EventArgs e)
        {
            if (this.FileUpload1.HasFile)
            {
                this.InitializeStorage();

                // upload the image to blob storage
                string uniqueBlobName = string.Format("guestbookpics/image_{0}{1}", Guid.NewGuid().ToString(), Path.GetExtension(this.FileUpload1.FileName));
                CloudBlockBlob blob = blobStorage.GetContainerReference("guestbookpics").GetBlockBlobReference(uniqueBlobName);
                blob.Properties.ContentType = this.FileUpload1.PostedFile.ContentType;
                blob.UploadFromStream(this.FileUpload1.FileContent);
                System.Diagnostics.Trace.TraceInformation("Uploaded image '{0}' to blob storage as '{1}'", this.FileUpload1.FileName, uniqueBlobName);

                // create a new entry in table storage
                GuestBookEntry entry = new GuestBookEntry() { GuestName = this.NameTextBox.Text, Message = this.MessageTextBox.Text, PhotoUrl = blob.Uri.ToString(), ThumbnailUrl = blob.Uri.ToString() };
                GuestBookDataSource ds = new GuestBookDataSource();
                ds.AddGuestBookEntry(entry);
                System.Diagnostics.Trace.TraceInformation("Added entry {0}-{1} in table storage for guest '{2}'", entry.PartitionKey, entry.RowKey, entry.GuestName);

                // queue a message to process the image
                var queue = queueStorage.GetQueueReference("guestthumbs");
                var message = new CloudQueueMessage(string.Format("{0},{1},{2}", uniqueBlobName, entry.PartitionKey, entry.RowKey));
                queue.AddMessage(message);
                System.Diagnostics.Trace.TraceInformation("Queued message to process blob '{0}'", uniqueBlobName);
            }

            this.NameTextBox.Text = string.Empty;
            this.MessageTextBox.Text = string.Empty;

            this.DataList1.DataBind();
        }
开发者ID:kirpasingh,项目名称:MicrosoftAzureTrainingKit,代码行数:31,代码来源:Default.aspx.cs


示例7: SendWebHookWorkItemsAsync

        /// <inheritdoc />
        public async Task SendWebHookWorkItemsAsync(IEnumerable<WebHookWorkItem> workItems)
        {
            if (workItems == null)
            {
                throw new ArgumentNullException("workItems");
            }

            CloudQueue queue = _manager.GetCloudQueue(_connectionString, WebHookQueue);

            try
            {
                IEnumerable<Task> addTasks = workItems.Select(item =>
                    {
                        string content = JsonConvert.SerializeObject(item, _serializerSettings);
                        CloudQueueMessage message = new CloudQueueMessage(content);
                        return queue.AddMessageAsync(message);
                    });
                await Task.WhenAll(addTasks);
            }
            catch (Exception ex)
            {
                string error = _manager.GetStorageErrorMessage(ex);
                string msg = string.Format(CultureInfo.CurrentCulture, AzureStorageResources.AzureSender_AddFailure, error);
                _logger.Error(msg, ex);
            }
        }
开发者ID:itomek,项目名称:WebHooks,代码行数:27,代码来源:AzureWebHookSender.cs


示例8: CloudQueueCreateMessageAsync

        public async Task CloudQueueCreateMessageAsync()
        {
            CloudQueue queue = DefaultQueueClient.GetQueueReference(TestHelper.GenerateNewQueueName());

            try
            {
                await queue.CreateIfNotExistsAsync();

                CloudQueueMessage message = new CloudQueueMessage(Guid.NewGuid().ToString());
                await queue.AddMessageAsync(message);

                CloudQueueMessage retrMessage = await queue.GetMessageAsync();
                string messageId = retrMessage.Id;
                string popReceipt = retrMessage.PopReceipt;

                // Recreate the message using the messageId and popReceipt.
                CloudQueueMessage newMessage = new CloudQueueMessage(messageId, popReceipt);
                Assert.AreEqual(messageId, newMessage.Id);
                Assert.AreEqual(popReceipt, newMessage.PopReceipt);

                await queue.UpdateMessageAsync(newMessage, TimeSpan.FromSeconds(30), MessageUpdateFields.Visibility);
                CloudQueueMessage retrMessage2 = await queue.GetMessageAsync();
                Assert.AreEqual(null, retrMessage2);
            }
            finally
            {
                queue.DeleteIfExistsAsync().AsTask().Wait();
            }
        }
开发者ID:jdkillian,项目名称:azure-sdk-for-net,代码行数:29,代码来源:CloudQueueMessageTest.cs


示例9: StartCrawling

 public static string StartCrawling()
 {
     CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
     CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
     CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
     CloudTable pageTable = tableClient.GetTableReference("indexedpages");
     while (pageTable.Exists())
     {
         System.Threading.Thread.Sleep(1000);
     }
     pageTable.CreateIfNotExists();
     Debug.WriteLine("Now in StartCrawling");
     CloudQueue cmdQ = queueClient.GetQueueReference("cmdq");
     cmdQ.CreateIfNotExists();
     CloudQueue urlQ = queueClient.GetQueueReference("pagequeue");
     urlQ.CreateIfNotExists();
     urlQ.Clear();
     urlQ.AddMessage(new CloudQueueMessage("http://www.cnn.com/robots.txt"));
     Debug.WriteLine("THIS IS THE MESSAGE ADDED: " + urlQ.PeekMessage().AsString);
     cmdQ.Clear();
     string message = "start";
     CloudQueueMessage cmd = new CloudQueueMessage(message);
     cmdQ.AddMessage(cmd);
     return message;
 }
开发者ID:hudpoi459,项目名称:Info344,代码行数:25,代码来源:Admin.asmx.cs


示例10: DeleteMessage

 public Task DeleteMessage(CloudQueueMessage message, QueueRequestOptions options = null, OperationContext operationContext = null, CancellationToken? cancellationToken = null)
 {
     return AsyncTaskUtil.RunAsyncCancellable(
         _inner.BeginDeleteMessage(message, options, operationContext, null, null),
         _inner.EndDeleteMessage,
         cancellationToken);
 }
开发者ID:Porges,项目名称:azure-storage-async,代码行数:7,代码来源:AsyncCloudQueue.cs


示例11: processQueueMessage

        protected override void processQueueMessage(CloudQueueMessage message)
        {
            base.processQueueMessage(message);

            var rawData = message.AsBytes;
            var stream = new MemoryStream(rawData);
            stream.Seek(0, SeekOrigin.Begin);

            var bFrmt = new BinaryFormatter();
            var resObject = bFrmt.Deserialize(stream);

            if (resObject is CloudQueueBlobMessage)
            {
                var cqbm = resObject as CloudQueueBlobMessage;
                var msgContentRef = container.GetBlockBlobReference(cqbm.BlobName);

                var msRes = new MemoryStream();
                msgContentRef.DownloadToStream(msRes);
                msRes.Seek(0, SeekOrigin.Begin);

                resObject = bFrmt.Deserialize(msRes);
            }

            processMessage(resObject);
        }
开发者ID:NewMediaCenterMoscow,项目名称:UniSocial3,代码行数:25,代码来源:BaseMessageBlobWorker.cs


示例12: AddMessage

 public Task AddMessage(CloudQueueMessage message, TimeSpan? timeToLive = null, TimeSpan? initialVisibilityDelay = null, QueueRequestOptions options = null, OperationContext operationContext = null, CancellationToken? cancellationToken = null)
 {
     return AsyncTaskUtil.RunAsyncCancellable(
         _inner.BeginAddMessage(message, timeToLive, initialVisibilityDelay, options, operationContext, null, null),
         _inner.EndAddMessage,
         cancellationToken);
 }
开发者ID:Porges,项目名称:azure-storage-async,代码行数:7,代码来源:AsyncCloudQueue.cs


示例13: Index

        public ActionResult Index(SendViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.SendBy == 0)
                    HostingEnvironment.QueueBackgroundWorkItem(ct => MessageSender.SendAsync(model));
                else if (model.SendBy == 1)
                {
                    BackgroundJob.Enqueue(() => MessageSender.SendWithEvent(model));
                }
                else
                {
                    //TODO send queue message to use WebJobs
                    var storageAccount = CloudStorageAccount.Parse(
                        ConfigurationManager.ConnectionStrings["AzureWebJobsStorage"].ConnectionString);
                    var queueClient = storageAccount.CreateCloudQueueClient();
                    var queue = queueClient.GetQueueReference("pending-mail");

                    // Create the queue if it doesn't already exist
                    queue.CreateIfNotExists();

                    var message = new CloudQueueMessage(JsonConvert.SerializeObject(model));
                    queue.AddMessage(message);
                }
                return RedirectToAction("Pending");
            }

            return View(model);
        }
开发者ID:yonglehou,项目名称:MailSender,代码行数:29,代码来源:SendController.cs


示例14: QueueListenerTests

        public QueueListenerTests()
        {
            CloudQueue queue = new CloudQueue(new Uri("https://test.queue.core.windows.net/testqueue"));
            Mock<IStorageQueue> mockQueue = new Mock<IStorageQueue>(MockBehavior.Strict);
            mockQueue.Setup(p => p.SdkObject).Returns(queue);

            _mockTriggerExecutor = new Mock<ITriggerExecutor<IStorageQueueMessage>>(MockBehavior.Strict);
            Mock<IDelayStrategy> mockDelayStrategy = new Mock<IDelayStrategy>(MockBehavior.Strict);
            Mock<IBackgroundExceptionDispatcher> mockExceptionDispatcher = new Mock<IBackgroundExceptionDispatcher>(MockBehavior.Strict);
            TextWriter log = new StringWriter();
            Mock<IQueueProcessorFactory> mockQueueProcessorFactory = new Mock<IQueueProcessorFactory>(MockBehavior.Strict);
            JobHostQueuesConfiguration queuesConfig = new JobHostQueuesConfiguration();
            QueueProcessorFactoryContext context = new QueueProcessorFactoryContext(queue, log, queuesConfig);

            _mockQueueProcessor = new Mock<QueueProcessor>(MockBehavior.Strict, context);
            JobHostQueuesConfiguration queueConfig = new JobHostQueuesConfiguration
            {
                MaxDequeueCount = 5,
                QueueProcessorFactory = mockQueueProcessorFactory.Object
            };

            mockQueueProcessorFactory.Setup(p => p.Create(It.IsAny<QueueProcessorFactoryContext>())).Returns(_mockQueueProcessor.Object);

            _listener = new QueueListener(mockQueue.Object, null, _mockTriggerExecutor.Object, mockDelayStrategy.Object, mockExceptionDispatcher.Object, log, null, queueConfig);

            CloudQueueMessage cloudMessage = new CloudQueueMessage("TestMessage");
            _storageMessage = new StorageQueueMessage(cloudMessage);
        }
开发者ID:Bjakes1950,项目名称:azure-webjobs-sdk,代码行数:28,代码来源:QueueListenerTests.cs


示例15: Remove

 public void Remove(CloudQueueMessage message)
 {
     if (message != null)
     {
         _queue.DeleteMessage(message);
     }
 }
开发者ID:rahulkarnthobb,项目名称:Ijepai-Poc,代码行数:7,代码来源:AzureMessageQueueProvider.cs


示例16: Post

        // POST api/values
        public void Post([FromBody]int value)
        {
            //the only admitted values are from 1 to 4
            if(value>=1 && value <= 4)
            {
                // Retrieve storage account from connection string
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                Microsoft.Azure.CloudConfigurationManager.GetSetting("StorageConnectionString"));

                // Create the queue client.
                CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();

                // Retrieve a reference to a queue.
                CloudQueue queue = queueClient.GetQueueReference("myqueue");

                // Create the queue if it doesn't already exist.
                queue.CreateIfNotExists();

                // Create a message and add it to the queue.
                CloudQueueMessage message = new CloudQueueMessage(value.ToString());
                queue.AddMessage(message);
            }
           


        }
开发者ID:isabelcabezasm,项目名称:Lego.EV3,代码行数:27,代码来源:ValuesController.cs


示例17: ProcessQueueMessage

        private void ProcessQueueMessage(CloudQueueMessage msg)
        {
            Trace.TraceInformation("Processing queue message {0}", msg);

            // Queue message contains AdId.
            var adId = int.Parse(msg.AsString);
            Ad ad = db.Ads.Find(adId);
            if (ad == null)
            {
                throw new Exception(String.Format("AdId {0} not found, can't create thumbnail", adId.ToString()));
            }

            CloudBlockBlob inputBlob = this.imagesBlobContainer.GetBlockBlobReference(ad.ImageURL);

            string thumbnailName = Path.GetFileNameWithoutExtension(inputBlob.Name) + "thumb.jpg";
            CloudBlockBlob outputBlob = this.imagesBlobContainer.GetBlockBlobReference(thumbnailName);

            using (Stream input = inputBlob.OpenRead())
            using (Stream output = outputBlob.OpenWrite())
            {
                ConvertImageToThumbnailJPG(input, output);
                outputBlob.Properties.ContentType = "image/jpeg";
            }
            Trace.TraceInformation("Generated thumbnail in blob {0}", thumbnailName);

            ad.ThumbnailURL = outputBlob.Uri.ToString();
            db.SaveChanges();
            Trace.TraceInformation("Updated thumbnail URL in database: {0}", ad.ThumbnailURL);

            // Remove message from queue.
            this.imagesQueue.DeleteMessage(msg);
        }
开发者ID:donnaknew,项目名称:programmingProject,代码行数:32,代码来源:WorkerRole.cs


示例18: Main

        static void Main()
        {
            Console.WriteLine("*************************************************************************");
            Console.WriteLine("WebJobUsageDaily:Main starting. DateTimeUTC: {0}", DateTime.UtcNow);

            List<Subscription> abis = Commons.Utils.GetSubscriptions();

            foreach (Subscription s in abis)
            {
                //Commons.Utils.UpdateSubscriptionStatus(s.Id, DataGenStatus.Pending, DateTime.UtcNow.AddYears(-3));
                try
                {
                    //DateTime sdt = DateTime.Now.AddYears(-3);
                    DateTime sdt = DateTime.Now.AddDays(-2);
                    DateTime edt = DateTime.Now;
                    BillingRequest br = new BillingRequest(s.Id, s.OrganizationId, sdt, edt);

                    // Insert into Azure Storage Queue
                    var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["AzureWebJobsStorage"].ToString());
                    CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
                    CloudQueue subscriptionsQueue = queueClient.GetQueueReference(ConfigurationManager.AppSettings["ida:QueueBillingDataRequests"].ToString());
                    subscriptionsQueue.CreateIfNotExists();
                    var queueMessage = new CloudQueueMessage(JsonConvert.SerializeObject(br));
                    subscriptionsQueue.AddMessageAsync(queueMessage);
                    Console.WriteLine(String.Format("Sent id for daily billing log: {0}", s.Id));

                    Commons.Utils.UpdateSubscriptionStatus(s.Id, DataGenStatus.Pending, DateTime.UtcNow);
                }
                catch (Exception e)
                {
                    Console.WriteLine("WebJobUsageDaily - SendQueue: " + e.Message);
                }
            } // foreach
        }
开发者ID:ChrisRisner,项目名称:AzureUsageAndBillingPortal,代码行数:34,代码来源:Program.cs


示例19: PushToResizeQueue

        public async Task PushToResizeQueue(BlobInformation blobInformation)
        {
            //var namespaceManager = NamespaceManager.CreateFromConnectionString(AppSettings.ServiceBusConnectionString);

            //if (!namespaceManager.QueueExists(AppSettings.ResizeQueueName))
            //{
            //    namespaceManager.CreateQueue(AppSettings.ResizeQueueName);
            //}
            //QueueClient Client = QueueClient.CreateFromConnectionString(AppSettings.ServiceBusConnectionString, AppSettings.ResizeQueueName);
            //Client.Send(new BrokeredMessage(blobInformation));

            try
            {
                CloudStorageAccount account;
                string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", AppSettings.StorageAccountName, AppSettings.StorageAccountKey);

                if (CloudStorageAccount.TryParse(storageConnectionString, out account))
                {
                    CloudQueueClient queueClient = account.CreateCloudQueueClient();
                    CloudQueue resizeRequestQueue = queueClient.GetQueueReference(AppSettings.ResizeQueueName);
                    resizeRequestQueue.CreateIfNotExists(); 

                    var queueMessage = new CloudQueueMessage(JsonConvert.SerializeObject(blobInformation));
                    await resizeRequestQueue.AddMessageAsync(queueMessage);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("Exception in QueueManager.PushToQueue => " + ex.Message);
            }

        }
开发者ID:cephalin,项目名称:ContosoMoments,代码行数:32,代码来源:QueueManager.cs


示例20: QueueActivity

    public static void QueueActivity(
      string userId, 
      EventType eventType, 
      string message)
    {
      try
      {
        var cloudStorageAccount = 
          CloudStorageAccount.Parse(
            CloudConfigurationManager.GetSetting("StorageConnectionString"));

        var queueReference = 
          cloudStorageAccount.CreateCloudQueueClient()
            .GetQueueReference("activity");

        queueReference.CreateIfNotExists();

        var activity = new Activity
        {
          UserId = userId,
          Event = eventType,
          Date = DateTime.Now,
          Message = message
        };

        var cloudQueueMessage = 
          new CloudQueueMessage(JsonConvert.SerializeObject(activity));

        queueReference.AddMessage(cloudQueueMessage);
      }
      catch (Exception exception)
      {
        Trace.TraceError(exception.Message);
      }
    }
开发者ID:rafaelmtz,项目名称:HeroVsRobot,代码行数:35,代码来源:ActivityService.cs



注:本文中的Microsoft.WindowsAzure.Storage.Queue.CloudQueueMessage类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Queue.QueueRequestOptions类代码示例发布时间:2022-05-26
下一篇:
C# Queue.CloudQueueClient类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap