次の方法で共有


ServiceBusRuleManagerAsyncClient クラス

  • java.lang.Object
    • com.azure.messaging.servicebus.ServiceBusRuleManagerAsyncClient

実装

public class ServiceBusRuleManagerAsyncClient
implements AutoCloseable

特定のトピック サブスクリプションのルールを管理する 非同期 ルール マネージャー。 ルール マネージャーではリッスン要求のみが必要ですが、 には要求の管理が ServiceBusAdministrationAsyncClient 必要です。

ルール マネージャーのインスタンスを作成する

// The required parameters is connectionString, a way to authenticate with Service Bus using credentials.
 // The connectionString/queueName must be set by the application. The 'connectionString' format is shown below.
 // "Endpoint={fully-qualified-namespace};SharedAccessKeyName={policy-name};SharedAccessKey={key}"
 TokenCredential credential = new DefaultAzureCredentialBuilder().build();

 // 'fullyQualifiedNamespace' will look similar to "{your-namespace}.servicebus.windows.net"
 ServiceBusRuleManagerAsyncClient ruleManager = new ServiceBusClientBuilder()
     .credential(fullyQualifiedNamespace, credential)
     .ruleManager()
     .topicName(topicName)
     .subscriptionName(subscriptionName)
     .buildAsyncClient();

Service Bus サブスクリプションに対するルールを作成する

RuleFilter trueRuleFilter = new TrueRuleFilter();
 CreateRuleOptions options = new CreateRuleOptions(trueRuleFilter);

 // `subscribe` is a non-blocking call. After setting up the create rule operation, it will move onto the next
 // line of code to execute.
 // Consider using Mono.usingWhen to scope the creation, usage, and cleanup of the rule manager.
 ruleManager.createRule("new-rule", options).subscribe(
     unused -> {
     },
     err -> System.err.println("Error occurred when create a rule, err: " + err),
     () -> System.out.println("Create complete.")
 );

 // Finally dispose of the rule manager when done using it.
 ruleManager.close();

すべてのルールをフェッチします。

// `subscribe` is a non-blocking call. After setting up the list rules operation, it will move onto the next
 // line of code to execute.
 ruleManager.listRules().subscribe(ruleProperties -> System.out.println(ruleProperties.getName()));

ルールを削除します。

// `subscribe` is a non-blocking call. After setting up the delete rule operation, it will move onto the next
 // line of code to execute.
 ruleManager.deleteRule("exist-rule").subscribe(
     unused -> { },
     err -> System.err.println("Error occurred when delete rule, err: " + err),
     () -> System.out.println("Delete complete.")
 );

メソッドの概要

修飾子と型 メソッドと説明
void close()

を破棄します ServiceBusRuleManagerAsyncClient

Mono<Void> createRule(String ruleName, CreateRuleOptions options)

現在のサブスクリプションに対して、トピックからサブスクリプションに到達するメッセージをフィルター処理するルールを作成します。

Mono<Void> deleteRule(String ruleName)

によって識別されるサブスクリプションのルールを ruleName削除します。

String getEntityPath()

Service Bus リソースの名前を取得します。

String getFullyQualifiedNamespace()

完全修飾名前空間を取得します。

Flux<RuleProperties> listRules()

トピックとサブスクリプションに関連付けられているすべてのルールをフェッチします。

メソッドの継承元: java.lang.Object

メソッドの詳細

close

public void close()

を破棄します ServiceBusRuleManagerAsyncClient。 クライアントに専用接続がある場合は、基になる接続も閉じられます。

createRule

public Mono createRule(String ruleName, CreateRuleOptions options)

現在のサブスクリプションに対して、トピックからサブスクリプションに到達するメッセージをフィルター処理するルールを作成します。

Parameters:

ruleName - ルールの名前。
options - 追加するルールのオプション。

Returns:

ルールの作成時に完了する Mono。

deleteRule

public Mono deleteRule(String ruleName)

によって識別されるサブスクリプションのルールを ruleName削除します。

Parameters:

ruleName - 削除するルールの名前。

Returns:

ルールが削除されたときに完了する Mono。

getEntityPath

public String getEntityPath()

Service Bus リソースの名前を取得します。

Returns:

Service Bus リソースの名前。

getFullyQualifiedNamespace

public String getFullyQualifiedNamespace()

完全修飾名前空間を取得します。

Returns:

完全修飾名前空間。

listRules

public Flux listRules()

トピックとサブスクリプションに関連付けられているすべてのルールをフェッチします。

Returns:

トピックとサブスクリプションに関連付けられているルールの一覧。

適用対象