Using the June 2012 Azure SDK, I have a service bus topic, and I am adding a subscription to it.
I want to filter that subscription. If I do this based on one of the items that I have added to the BrokeredMessage Properties bag, then this works fine:
// 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();
If, however, I do the same, but add the filter value to one of the direct properties of the BrokeredMessage object, such as SessionId, then this fails:
// 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();
How can I construct an SqlFilter that will address the built-in properties of the BrokeredMessage object (SessionId, or ReplyToSessionId, or MessageId?
Is this even possible?
The property expressions in SQL filters actually have scoping prefixes. You usually don't see them, because the default is "user." for the user-defined properties. You can get at the system properties by prefixing with "sys."
See syntax description here; look for 'scope' http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.servicebus.messaging.sqlfilter.sqlexpression.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With