You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/service-bus-messaging/topic-filters.md
+86-65Lines changed: 86 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Azure Service Bus topic filters | Microsoft Docs
3
3
description: This article explains how subscribers can define which messages they want to receive from a topic by specifying filters.
4
4
ms.topic: conceptual
5
-
ms.date: 10/05/2022
5
+
ms.date: 02/28/2023
6
6
---
7
7
8
8
# Topic filters and actions
@@ -24,69 +24,92 @@ In this example, if you send one message that matches all five rules, you get th
24
24
Each newly created topic subscription has an initial default subscription rule. If you don't explicitly specify a filter condition for the rule, the applied filter is the **true** filter that enables all messages to be selected into the subscription. The default rule has no associated annotation action.
25
25
26
26
## Filters
27
-
Service Bus supports three filter conditions:
28
-
29
-
-*SQL Filters* - A **SqlFilter** holds a SQL-like conditional expression that is evaluated in the broker against the arriving messages' user-defined properties and system properties. All system properties must be prefixed with `sys.` in the conditional expression. The [SQL-language subset for filter conditions](service-bus-messaging-sql-filter.md) tests for the existence of properties (`EXISTS`), null-values (`IS NULL`), logical NOT/AND/OR, relational operators, simple numeric arithmetic, and simple text pattern matching with `LIKE`.
-*CorrelationFilters*-A**CorrelationFilter**holdsasetofconditionsthatarematchedagainstoneormoreofanarrivingmessage's user and system properties. A common use is to match against the **CorrelationId** property, but the application can also choose to match against the following properties:
60
-
61
-
-**ContentType**
62
-
-**Label**
63
-
-**MessageId**
64
-
-**ReplyTo**
65
-
-**ReplyToSessionId**
66
-
-**SessionId**
67
-
-**To**
68
-
-anyuser-definedproperties.
27
+
Service Bus supports three types of filters:
28
+
29
+
- SQL filters
30
+
- Boolean filters
31
+
- Correlation filters
32
+
33
+
The following sections provide details about these filters.
34
+
35
+
### SQL filters
36
+
A **SqlFilter** holds a SQL-like conditional expression that's evaluated in the broker against the arriving messages' user-defined properties and system properties. All system properties must be prefixed with `sys.` in the conditional expression. The [SQL-language subset for filter conditions](service-bus-messaging-sql-filter.md) tests for the existence of properties (`EXISTS`), null-values (`IS NULL`), logical `NOT`/`AND`/`OR`, relational operators, simple numeric arithmetic, and simple text pattern matching with `LIKE`.
A**CorrelationFilter**holdsasetofconditionsthatarematchedagainstoneormoreofanarrivingmessage's user and system properties. A common use is to match against the **CorrelationId** property, but the application can also choose to match against the following properties:
71
+
72
+
- `ContentType`
73
+
- `Label`
74
+
- `MessageId`
75
+
- `ReplyTo`
76
+
- `ReplyToSessionId`
77
+
- `SessionId`
78
+
- `To`
79
+
-anyuser-definedproperties.
69
80
70
-
Amatchexistswhenanarrivingmessage's value for a property is equal to the value specified in the correlation filter. For string expressions, the comparison is case-sensitive. If you specify multiple match properties, the filter combines them as a logical AND condition, meaning for the filter to match, all conditions must match.
81
+
Amatchexistswhenanarrivingmessage's value for a property is equal to the value specified in the correlation filter. For string expressions, the comparison is case-sensitive. If you specify multiple match properties, the filter combines them as a logical AND condition, meaning for the filter to match, all conditions must match.
71
82
72
-
**.NETexamplefordefiningacorrelationfilter:**
83
+
Here's a .NET example for defining a correlation filter:
73
84
74
-
```csharp
75
-
// Create a correlation filter with color set to Red and priority set to High
Complexfilterrulesrequireprocessingcapacity. Inparticular, theuseofSQLfilterrulescauseloweroverallmessagethroughputatthesubscription, topic, andnamespacelevel. Wheneverpossible, applicationsshouldchoosecorrelationfiltersoverSQL-likefiltersbecausethey're much more efficient in processing and have less impact on throughput.
>Allfiltersevaluatemessageproperties. Filterscan't evaluate the message body.
107
+
>Complexfilterrulesrequireprocessingcapacity. Inparticular, theuseofSQLfilterrulescauseloweroverallmessagethroughputatthesubscription, topic, andnamespacelevel. Wheneverpossible, applicationsshouldchoosecorrelationfiltersoverSQL-likefiltersbecausethey're much more efficient in processing and have less impact on throughput.
Partitioningusesfilterstodistributemessagesacrossseveralexistingtopicsubscriptionsinapredictableandmutuallyexclusivemanner. Thepartitioningpatternisused when a system is scaled out to handle many different contexts in functionally identical compartments that each hold a subset of the overall data; for example, customer profile information. With partitioning, a publisher submits the message into a topic without requiring any knowledge of the partitioning model. The message then is moved to the correct subscription from which it can then be retrieved by the partition's message handler.
Partitioningusesfilterstodistributemessagesacrossseveralexistingtopicsubscriptionsinapredictableand**mutuallyexclusive**manner. Thepartitioningpatternisused when a system is scaled out to handle many different contexts in functionally identical compartments that each hold a subset of the overall data; for example, customer profile information. With partitioning, a publisher submits the message into a topic without requiring any knowledge of the partitioning model. The message then is moved to the correct subscription from which it can then be retrieved by the partition's message handler.
0 commit comments