使用 2012 年 6 月的 Azure SDK,我有一个服务总线主题,我正在向它添加订阅。
我想过滤该订阅。如果我根据我添加到 BrokeredMessage 属性包中的一项来执行此操作,那么这可以正常工作:
// 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();
但是,如果我执行相同操作,但将过滤器值添加到 BrokeredMessage 对象的直接属性之一,例如 SessionId,则此操作将失败:
// 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();
如何构造一个 SqlFilter 来处理 BrokeredMessage 对象的内置属性(SessionId、ReplyToSessionId 或 MessageId?
这甚至可能吗?