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