我正在尝试构建一个事件驱动的Azure队列,每次将消息放入Azure队列时都会触发事件。使用AzureXplorer,我看到消息正确放入Azure队列,但CloudQueueClient.ResponseReceived事件永远不会触发。我正在使用Azure V1.4。这是我的Worker角色的代码:
public class WorkerRole : RoleEntryPoint
{
public override void Run()
{
while (true)
{
Thread.Sleep(10000);
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
var queuDataSource = new AzureQueueDataSource();
queuDataSource.GetCloudQueueClient().ResponseReceived +=new EventHandler<ResponseReceivedEventArgs>(WorkerRole_ResponseReceived);
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
return base.OnStart();
}
void WorkerRole_ResponseReceived(object sender, ResponseReceivedEventArgs e)
{
var i = 1; // Breakpoint here never happends
}
}
答案 0 :(得分:4)
需要针对新邮件轮询Windows Azure队列。有关如何查询新邮件队列的示例,请参阅SDK示例或代码here。
要考虑的事项的快速列表:
所有这些都有很多报道。请参阅上面链接中的文档/示例。这篇文章也很不错:http://blogs.msdn.com/b/appfabriccat/archive/2010/12/20/best-practices-for-maximizing-scalability-and-cost-effectiveness-of-queue-based-messaging-solutions-on-windows-azure.aspx