1

I've subscribed to a topic and the sender sets two UserProperties 'Classification' and 'SubClassification'. I want to filter the messages with Classification set to 1. I tried adding the following SqlFilter.

SqlFilter("Classification='1'")

It doesn't work. I still receive all the messages irrespective of the 'Classification' property.

I'm using the Subscription client from Microsoft.Azure.ServiceBus namespace.

vamshi s
  • 11
  • 1
  • 1
    Have you checked that there's no default rule on that subscription? It's created by default. Share the code you use to create your subscription. – Sean Feldman Nov 16 '18 at 05:02

2 Answers2

0

You don't need to use SqlFilter() inside the Rule. Just setting it as Classification='1' will filter the messages.

Arunprabhu
  • 1,454
  • 9
  • 15
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://learn.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);
granadaCoder
  • 26,328
  • 10
  • 113
  • 146