SqlRuleAction Class
- java.
lang. Object - com.
azure. messaging. servicebus. administration. models. RuleAction - com.
azure. messaging. servicebus. administration. models. SqlRuleAction
- com.
- com.
public class SqlRuleAction
extends RuleAction
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:
- getCorrelationId() equal to
"email" - getApplicationProperties() contains a key
"sender"with value"joseph" - 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 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());
Constructor Summary
| Constructor | Description |
|---|---|
| SqlRuleAction(String sqlExpression) |
Creates a new instance with the given SQL expression. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
| Map<String,Object> |
getParameters()
Gets the properties for this action. |
| String |
getSqlExpression()
Gets the SQL expression. |
Methods inherited from java.lang.Object
Constructor Details
SqlRuleAction
public SqlRuleAction(String sqlExpression)
Creates a new instance with the given SQL expression.
Parameters:
Method Details
getParameters
public Map<String,Object> getParameters()
Gets the properties for this action.
Returns:
getSqlExpression
public String getSqlExpression()
Gets the SQL expression.
Returns: