2012-08-28 21 views
11

Utilizzando l'SDK di Azure di giugno 2012, ho un argomento sul bus di servizio e sto aggiungendo un abbonamento.Come filtrare una sottoscrizione all'argomento ServiceBus in base a una proprietà incorporata della classe BrokeredMessage?

Voglio filtrare quell'abbonamento. Se faccio questo in base a uno degli elementi che ho aggiunto alla borsa BrokeredMessage Proprietà, quindi questo funziona bene:

// Send the message: 
BrokeredMessage message = new BrokeredMessage(serializableObject); 
message.Properties.Add("MySessionId", "GUID"); 
getTopicClient("MY_TOPIC").Send(message); // method creates client. omitted here. 

// Retrieve it: 
SqlFilter myFilter = new SqlFilter(@"(MySessionId = ""GUID"")"); 
namespaceManager.CreateSubscription("MY_TOPIC", "MY_SUB", myFilter); 
SubscriptionClient client = getSubscriptionClient("MY_TOPIC", "MY_SUB"); // method creates client. omitted here. 

// This will work fine: 
Message newMessage = client.Receive(); 

Se, invece, faccio lo stesso, ma aggiungere il valore di filtro a una delle proprietà diretta dell'oggetto BrokeredMessage, come SessionId, allora questo non riesce:

// Send the message: 
BrokeredMessage message = new BrokeredMessage(serializableObject); 
message.SessionId = "GUID"; 
getTopicClient("MY_TOPIC").Send(message); // method creates client. omitted here. 

// Retrieve it: 
SqlFilter myFilter = new SqlFilter(@"(SessionId = ""GUID"")"); 
namespaceManager.CreateSubscription("MY_TOPIC", "MY_SUB", myFilter); 
SubscriptionClient client = getSubscriptionClient("MY_TOPIC", "MY_SUB"); // method creates client. omitted here. 

// This will never receive a message 
Message newMessage = client.Receive(); 

Come posso costruire uno SqlFilter che affronterà il built-in proprietà dell'oggetto BrokeredMessage (sessionid, o ReplyToSessionId, o MessageId

?

È anche possibile?

risposta

18

Le espressioni di proprietà nei filtri SQL dispongono effettivamente di prefissi di ambito. Di solito non li vedi, perché l'impostazione predefinita è "utente". per le proprietà definite dall'utente. È possibile ottenere le proprietà di sistema tramite il prefisso con "sys".

Vedere la descrizione della sintassi qui; cercare 'scope' http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.servicebus.messaging.sqlfilter.sqlexpression.aspx

+0

Esattamente quello che stavo cercando. Grazie molto! – JcFx

Problemi correlati