[英]Windows Azure Queue - CloudQueue.GetMessage() not working for latest version of Microsoft.WindowsAzure.Storage (v5.0.0)
I'm new to Azure and trying out the tutorial here . 我是Azure的新手, 在这里尝试教程。
The tutorial is about creating a Cloud Service on Azure taking advantage of the Web Role delegating task to the Worker Role. 本教程是关于在Azure上创建Cloud Service,利用Web角色委派任务到Worker Role。 The only part that matters;
唯一重要的部分; when user uploads an image to the Web Role, the Web Role will put the image in Azure Storage and create a new record in the database with a field containing the URL of the stored image.
当用户将图像上载到Web角色时,Web角色会将图像放入Azure存储中,并使用包含存储图像的URL的字段在数据库中创建新记录。 The Web Role next places a message (the ID of the newly added record) in Azure Queue.
Web角色接下来在Azure队列中放置一条消息(新添加的记录的ID)。
var queueMessage = new CloudQueueMessage(id);
await _cloudQueue.AddMessageAsync(queueMessage);
The Worker Role will then retrieve the message from the queue. 然后,Worker Role将从队列中检索消息。 Next, retrieve the record from the database.
接下来,从数据库中检索记录。 Then create a thumbnail from the image url of the retrieved database record.
然后从检索到的数据库记录的图像URL创建缩略图。
while (true) {
var msg = _cloudQueue.GetMessage();
if (msg != null) {
CreateThumbnail();
}
System.Threading.Thread.Sleep(1000);
}
The tutorial offers guidance to 本教程提供了指导
The solution works fine when using the downloaded source files. 使用下载的源文件时,该解决方案工作正常。 In the Worker Role,
var msg = _cloudQueue.GetMessage();
在Worker Role中,
var msg = _cloudQueue.GetMessage();
. 。
msg
always has something (not null) albeit there's a delay of 3 to 4 seconds after the image is uploaded. msg
总是有东西(不是null),虽然上传图像后会有3到4秒的延迟。 Therefore CreateThumbnail()
is always executed 3 to 4 seconds after the image is uploaded. 因此,在上传图像后3到4秒始终执行
CreateThumbnail()
。
However, if I were to create the solution from scratch, msg
is always null no matter how long I waited and CreateThumbnail
was never executed. 但是,如果我从头开始创建解决方案,无论我等待多长时间并且从未执行过
CreateThumbnail
, msg
始终为null。 I made sure the Worker Role was indeed running by putting breakpoint here and there. 我通过在这里和那里放置断点来确保工作者角色确实在运行。
After a few painstaking hours, I have boiled the problem down to the assembly Microsoft.WindowsAzure.Storage
. 经过几个艰苦的工作,我把问题归结为程序集
Microsoft.WindowsAzure.Storage
。 The solution source files downloaded from the tutorial page is using version 3.2.0 while the solution created from scratch is using the latest version 5.0.0 from NuGet. 从教程页面下载的解决方案源文件使用的是3.2.0版本,而从头开始创建的解决方案使用的是NuGet的最新版本5.0.0。 So in order words,
msg
is always null if I'm using the latest version 5.0.0 of Microsoft.WindowsAzure.Storage
on the Worker Role. 所以按顺序说,如果我在Worker Role上使用最新的5.0.0版本的
Microsoft.WindowsAzure.Storage
, msg
总是为null。 Is this a known issue or am I missing something. 这是一个已知问题还是我遗漏了一些东西。
I'm sorry you've had difficulty getting this tutorial to work. 对不起,你很难让这个教程发挥作用。 I've checked with the owner of the tutorial, and it's been recently updated (around 9/1).
我已经与教程的所有者核实了,并且最近更新了(大约9/1)。 Please download the new version of the Visual Studio solution and try it again.
请下载新版本的Visual Studio解决方案并再次尝试。
There are a few things to keep in mind, which are outlined in the troubleshooting section of the tutorial: 有几点需要注意,本教程的故障排除部分对此进行了概述:
From the tutorial: 从教程:
By default new cloud service projects use the Azure compute emulator express to simulate the Azure environment. 默认情况下,新的云服务项目使用Azure计算模拟器来模拟Azure环境。 This is a lightweight version of the full compute emulator, and under some conditions the full emulator will work when the express version does not.
这是完整计算模拟器的轻量级版本,在某些情况下,当快速版本没有时,完整模拟器将起作用。
To change the project to use the full emulator, right-click the ContosoAdsCloudService project, and then click Properties. 若要更改项目以使用完整模拟器,请右键单击ContosoAdsCloudService项目,然后单击“属性”。 In the Properties window click the Web tab, and then click the Use Full Emulator radio button.
在“属性”窗口中,单击“Web”选项卡,然后单击“使用完全模拟器”单选按钮。
In order to run the application with the full emulator, you have to open Visual Studio with administrator privileges. 要使用完整模拟器运行应用程序,必须使用管理员权限打开Visual Studio。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.