2013-05-02 40 views
1

我正在爲使用主題/訂閱的雲服務創建SQL篩選器。我宣佈我的斡旋消息的屬性,它看起來像這樣Windows Azure中的SQL篩選器問題主題

BrokeredMessage message = new BrokeredMessage("Response Message#"+ (++counter) +" Body"); 

// Set additional custom app-specific property 
message.Properties["MsgGUID"] = RequestMessageID; //assign msgGUID read from the Azure Queue 

// Send message to the topic 
Client.Send(message); 

什麼是要實現的是,當我發送郵件到我的輔助角色,該消息將包含隨機生成的字符串。工作者角色會將該字符串視爲我的ID並創建一個代理消息,其「MsgGUID」屬性將保存該代理。我的SQL過濾器如下所示:

SqlFilter CompareGUIDFilter = new SqlFilter("MsgGUID = '" + messageID + "'");//Filter based on the Requested GUID i.e. msgGUID 

if (!nameSpaceManager.SubscriptionExists("TestTopic", "RequestMessageGUIDSubscriber")) 
      { 
       /*Subscriber with Filter as Receive only those Messages from the Topic that are 
       requested by the controller from another RequestQueue(Azure Queue) with GUID as messageID*/ 
       nameSpaceManager.CreateSubscription("TestTopic", "RequestMessageGUIDSubscriber", CompareGUIDFilter); 

      } 

我的隨機生成的字符串如下所示:

public string GetRandomString(int length) 
     { 
      Random r = new Random(); 
      string result = ""; 
      for (int i = 0; i < length; i++) 
      { 
       result += allowedchars.Substring(r.Next(0,allowedchars.Length),1); 
      } 
      return result; 
     } 

現在的問題是,當我設置MESSAGEID的東西一成不變的,像「GUID」,然後該過濾器正常工作,但是當我使用上述功能生成它時,它不起作用。任何幫助,將不勝感激。

回答

0

在sql過濾器中沒有問題。但是該主題使用該ID鍵值持久保存該消息。因此,您無法通過訂閱者訪問後面的消息。