2011-03-27 6 views
2

메시지가 Azure Queue에 입력 될 때마다 이벤트가 발생하는 Azure Queue 이벤트 구동 방식을 구축하려고합니다. AzureXplorer을 사용하면 메시지가 Azure Queue에 제대로 저장되지만 CloudQueueClient.ResponseReceived 이벤트는 실행되지 않습니다. 저는 Azure V1.4를 사용하고 있습니다. 내 작업자 역할의 코드입니다.CloudQueueClient.ResponseReceived 이벤트가 손상 되었습니까?

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 
    } 
} 

답변

4

Windows Azure 대기열은 새 메시지에 대해 폴링해야합니다. 새 메시지 큐를 쿼리하는 방법에 대한 예제는 SDK 샘플 또는 코드 here을 참조하십시오. 고려해야 할 것들

빠른 목록 : 폴링이 윈도우 Azure에서 거래로 계산됩니다

  1. 때문에 그 비용을 지불한다.
  2. 메시지가없는 경우 일종의 재시도 메커니즘을 구현하는 것이 더 좋습니다 (예 : 지수 백 오프 등)
  3. 일괄 적으로 메시지를 검색하는 것이 좋습니다 (왕복 횟수 감소, 트랜잭션 감소 등)
  4. 메시지가 한 번 (중복 메시지에 대한 계획)
  5. 사용 "dequeuecount"속성 "포이즌 메시지"를 처리하는 것보다 더 전달 될 수 있다는 것을 기억하십시오.

여기에는 많은 내용이 포함되어 있습니다. 위의 링크에서 설명서/샘플을 참조하십시오. 이 기사는 역시 좋다 : 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

+0

글쎄, 그건 슬픈 일이다. 마케팅 부서에서 욕심 많은 사람들이 그렇게했다고 생각하니?! ;) ... –

+0

음, 긍정적 인 측면에서, 잘 설계된 앱을 개발하기위한 인센티브를 갖는 것이 다소 좋은가요? 그리고, MS는 그것을 만들거나 대기열 수익으로 중단하지 않을 것입니다 :-) –

관련 문제