Sdílet prostřednictvím


SqlRuleAction Class

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:

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:

sqlExpression - SQL expression for the action.

Method Details

getParameters

public Map getParameters()

Gets the properties for this action.

Returns:

the properties for this action.

getSqlExpression

public String getSqlExpression()

Gets the SQL expression.

Returns:

the SQL expression.

Applies to