Class ServiceBusRuleManagerClient
java.lang.Object
com.azure.messaging.servicebus.ServiceBusRuleManagerClient
- All Implemented Interfaces:
AutoCloseable
A synchronous rule manager responsible for managing rules for a specific topic subscription. The rule manager
requires only Listen claims, whereas the
ServiceBusAdministrationAsyncClient requires Manage claims.
Create a rule to a Service Bus subscription
TokenCredential credential = new DefaultAzureCredentialBuilder().build();
// 'fullyQualifiedNamespace' will look similar to "{your-namespace}.servicebus.windows.net"
ServiceBusRuleManagerClient ruleManager = new ServiceBusClientBuilder()
.credential(fullyQualifiedNamespace, credential)
.ruleManager()
.topicName(topicName)
.subscriptionName(subscriptionName)
.buildClient();
RuleFilter trueRuleFilter = new TrueRuleFilter();
CreateRuleOptions options = new CreateRuleOptions(trueRuleFilter);
ruleManager.createRule("new-rule", options);
// Dispose of the ruleManager when finished using it.
ruleManager.close();
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Disposes of theServiceBusRuleManagerClient.voidcreateRule(String ruleName, CreateRuleOptions options) Creates a rule to the current subscription to filter the messages reaching from topic to the subscription.voiddeleteRule(String ruleName) Removes the rule on the subscription identified byruleName.Gets the name of the Service Bus resource.Gets the fully qualified namespace.com.azure.core.util.IterableStream<RuleProperties> Fetches all rules associated with the topic and subscription.
-
Method Details
-
getFullyQualifiedNamespace
Gets the fully qualified namespace.- Returns:
- The fully qualified namespace.
-
getEntityPath
Gets the name of the Service Bus resource.- Returns:
- The name of the Service Bus resource.
-
createRule
Creates a rule to the current subscription to filter the messages reaching from topic to the subscription.- Parameters:
ruleName- Name of rule.options- The options for the rule to add.- Throws:
NullPointerException- ifoptions,ruleNameis null.IllegalStateException- if client is disposed.IllegalArgumentException- ifruleNameis empty string, action ofoptionsis not null and not instanceofSqlRuleAction, filter ofoptionsis not instanceofSqlRuleFilterorCorrelationRuleFilter.ServiceBusException- if filter matchesruleNameis already created in subscription.
-
listRules
Fetches all rules associated with the topic and subscription.- Returns:
- A list of rules associated with the topic and subscription.
- Throws:
IllegalStateException- if client is disposed.UnsupportedOperationException- if client cannot support filter with descriptor in message body.
-
deleteRule
Removes the rule on the subscription identified byruleName.- Parameters:
ruleName- Name of rule to delete.- Throws:
NullPointerException- ifruleNameis null.IllegalStateException- if client is disposed.IllegalArgumentException- ifruleNameis empty string.ServiceBusException- if cannot find filter matchesruleNamein subscription.
-
close
public void close()Disposes of theServiceBusRuleManagerClient. If the client has a dedicated connection, the underlying connection is also closed.- Specified by:
closein interfaceAutoCloseable
-