Reputation: 611
I'm using Azure Service Bus Explorer in managing subscriptions for existing Azure Service Bus topics. Now we have a new Topic that will receive messages from multiple source systems. Based on the source system i need to create different subscriptions. Below are the sample messages that we recieve
Message1:
{
"entity": {
"id": "20190501",
"source": "system1",
"body": "{\r\n \"Addressid\": \"74C9\",\r\n \"Start\": \"2016-07-17T21:06:10.983\",\r\n \"OrgID\": \"7204055\",\r\n \"Email\": \"[email protected]\",\r\n \"DeptID\": 998\r\n}",
"createDate": "2019-05-16T12:47:52.4658011Z",
"isDeleted": false
},
"operation": "POST"
}
Message2:
{
"entity": {
"id": "20190501",
"source": "system2",
"body": "{\r\n \"AC_ID\": \"74C9\",\r\n \"Name\": \"Name1\",\r\n \"InventoryID\": \"4055\",\r\n \"OtherID\": 998\r\n}",
"createDate": "2019-05-16T12:47:52.4658011Z",
"isDeleted": false
},
"operation": "POST"
}
I need to create two subscriptions with filter condition
Subscription1: with filter as "source": "system1"
Subscription2: with filter as "source": "system2"
Please help with me correct filter expression for the above service bus subscriptions that i need to create using service bus explorer.
Upvotes: 3
Views: 7737
Reputation: 26057
Azure Service Bus subscriptions operate on message headers/properties only.
You can have either Boolean, Correlation, or SQL filters. SQLFilter
class implements filtering that is beyond simple comparison and the syntax is a SQL-language based.
For example, "user.source='system1'"
or "user.source in ('system1', 'system2')"
In your scenario, I'd use a correlation filter just because there's no need in SQL filter complexity. As well as you're interested in subscriptions, each with a distinct value used for filtering messages out. You'll find an example in this post.
Regardless if you use SQL of Correlation filter, filtering can only take place on the properties. You'll have to promote "source" value from the body of your message into one of the headers, system header or a custom header.
To see topics in action, there are a few official samples:
Upvotes: 4