1

我订阅了一个主题,发件人设置了两个用户属性“分类”和“子分类”。我想过滤分类设置为 1 的消息。我尝试添加以下 SqlFilter。

SqlFilter("分类='1'")

它不起作用。无论“分类”属性如何,我仍然会收到所有消息。

我正在使用 Microsoft.Azure.ServiceBus 命名空间中的订阅客户端。

4

2 回答 2

0

您不需要SqlFilter()在规则内使用。只需将其设置为Classification='1'将过滤消息。

于 2018-11-16T04:55:18.100 回答
0

Try this to debug: (it will always match initially, but then you get rid of the

OR 1=1

after things are working. .

RuleDescription rd = new RuleDescription();
rd.Filter = new SqlFilter("CustomProperty = '1' OR 1=1");

Then you can tweak the syntax sugar as needed.

https://docs.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.sqlfilter?view=azure-dotnet

You should show YOUR code on how you create the subscription. Below is some code.. as an example:

NamespaceManager nsm = /* outside of scope of this question */
SubscriptionDescription currentSubscriptionDescription = new SubscriptionDescription("MyTopicPath", "MySubscriptionName");
currentSubscriptionDescription.AutoDeleteOnIdle = false;
SubscriptionDescription postCreateSd = nsm.CreateSubscription(currentSubscriptionDescription);


/* now tweak it */
MessagingFactory mf = /* outside of scope of this question */
SubscriptionClient subClient = mf.CreateSubscriptionClient("MyTopicPath", "MySubscriptionName");
RuleDescription rd = new RuleDescription();
rd.Filter = new SqlFilter("CustomProperty = '1' OR 1=1");
subClient.AddRule(rd);
于 2019-08-20T19:05:06.863 回答