CloudQueueClient.ResponseReceived事件已损坏?

时间:2011-03-27 12:31:34

标签: azure azure-queues

我正在尝试构建一个事件驱动的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
    }
}

1 个答案:

答案 0 :(得分:4)

需要针对新邮件轮询Windows Azure队列。有关如何查询新邮件队列的示例,请参阅SDK示例或代码here

要考虑的事项的快速列表:

  1. 因为投票被视为一个 您在Windows Azure中处理事务 将支付那些费用。
  2. 如果没有找到任何消息(例如指数退避等),通常最好实施某种重试机制
  3. 通常可以批量检索邮件(减少往返次数,减少交易次数等)
  4. 请记住,邮件可以多次发送(计划重复邮件)
  5. 使用“ dequeuecount ”属性处理“有害消息”。
  6. 所有这些都有很多报道。请参阅上面链接中的文档/示例。这篇文章也很不错: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