Class SqlRuleAction
java.lang.Object
com.azure.messaging.servicebus.administration.models.RuleAction
com.azure.messaging.servicebus.administration.models.SqlRuleAction
Represents set of actions written in SQL language-based syntax that is performed against a
ServiceBusMessage.
Sample: Create SQL rule filter with SQL rule action
The code sample below creates a rule using a SQL filter and SQL action. The rule matches messages with:
ServiceBusMessage.getCorrelationId()equal to"email"ServiceBusMessage.getApplicationProperties()contains a key"sender"with value"joseph"ServiceBusMessage.getApplicationProperties()contains a key"importance"with value *"joseph"OR the value is NULL.
If the filter matches, it will set/update the "importance" key in
ServiceBusMessage.getApplicationProperties() with "critical".
String topicName = "emails";
String subscriptionName = "important-emails";
String ruleName = "emails-from-joseph";
RuleFilter sqlRuleFilter = new SqlRuleFilter(
"sys.CorrelationId = 'email' AND sender = 'joseph' AND (importance IS NULL OR importance = 'high')");
RuleAction sqlRuleAction = new SqlRuleAction("SET importance = 'critical';");
CreateRuleOptions createRuleOptions = new CreateRuleOptions()
.setFilter(sqlRuleFilter)
.setAction(sqlRuleAction);
RuleProperties rule = client.createRule(topicName, ruleName, subscriptionName, createRuleOptions);
System.out.printf("Rule '%s' created for topic %s, subscription %s. Filter: %s%n", rule.getName(), topicName,
subscriptionName, rule.getFilter());
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSqlRuleAction(String sqlExpression) Creates a new instance with the given SQL expression. -
Method Summary
Modifier and TypeMethodDescriptionGets the properties for this action.Gets the SQL expression.
-
Constructor Details
-
SqlRuleAction
Creates a new instance with the given SQL expression.- Parameters:
sqlExpression- SQL expression for the action.- Throws:
NullPointerException- ifsqlExpressionis null.IllegalArgumentException- ifsqlExpressionis an empty string.
-
-
Method Details
-
getParameters
-
getSqlExpression
-