QueueServiceClientBuilder クラス

  • java.lang.Object
    • com.azure.storage.queue.QueueServiceClientBuilder

実装

public final class QueueServiceClientBuilder
implements TokenCredentialTrait<QueueServiceClientBuilder>, ConnectionStringTrait<QueueServiceClientBuilder>, AzureNamedKeyCredentialTrait<QueueServiceClientBuilder>, AzureSasCredentialTrait<QueueServiceClientBuilder>, HttpTrait<QueueServiceClientBuilder>, ConfigurationTrait<QueueServiceClientBuilder>, EndpointTrait<QueueServiceClientBuilder>

このクラスは、 と QueueServiceAsyncClientの構成とインスタンス化QueueServiceClientを支援する fluent Builder API を提供します。 を呼び出すとbuildClient()、QueueServiceClient のインスタンスが構築され、 を呼び出すと buildAsyncClient() QueueServiceAsyncClient のインスタンスが構築されます。

クライアントには、Azure Storage Queue サービスのエンドポイント、共有の名前、および承認資格情報が必要です。 endpoint(String endpoint) はビルダーにエンドポイントを提供し、ビルダーにクライアントを承認する SAS トークンを与える場合があります。

SAS トークンを使用した同期キュー サービス クライアントのインスタンス化

QueueServiceClient client = new QueueServiceClientBuilder()
     .endpoint("https://${accountName}.queue.core.windows.net?${SASToken}")
     .buildClient();

SAS トークンを使用した非同期キュー サービス クライアントのインスタンス化

QueueServiceAsyncClient client = new QueueServiceClientBuilder()
     .endpoint("https://{accountName}.queue.core.windows.net?{SASToken}")
     .buildAsyncClient();

endpoint SAS トークンを構築するためのクエリ パラメーターが含まれていない場合は、エンドポイントと共に を使用して sasToken(String sasToken) 設定できます。

SAS トークンを使用した同期キュー サービス クライアントのインスタンス化

QueueServiceAsyncClient client = new QueueServiceClientBuilder()
     .endpoint("https://{accountName}.queue.core.windows.net")
     .sasToken("{SASTokenQueryParams}")
     .buildAsyncClient();

SAS トークンを使用した非同期キュー サービス クライアントのインスタンス化

QueueServiceAsyncClient client = new QueueServiceClientBuilder()
     .endpoint("https://{accountName}.queue.core.windows.net")
     .sasToken("{SASTokenQueryParams}")
     .buildAsyncClient();

クライアントを認証するもう 1 つの方法は、 を使用することです StorageSharedKeyCredential。 StorageSharedKeyCredential を作成するには、ストレージ キュー サービスからの接続文字列を使用する必要があります。 StorageSharedKeyCredential を に connectionString(String connectionString)設定します。 ビルダーに SAS トークンと StorageSharedKeyCredential の両方がある場合、サービスに送信された要求を承認するときに StorageSharedKeyCredential が優先されます。

接続文字列を使用した同期キュー サービス クライアントのインスタンス化。

String connectionString = "DefaultEndpointsProtocol=https;AccountName={name};"
     + "AccountKey={key};EndpointSuffix={core.windows.net}";
 QueueServiceClient client = new QueueServiceClientBuilder()
     .connectionString(connectionString)
     .buildClient();

接続文字列を使用した非同期キュー サービス クライアントのインスタンス化。

String connectionString = "DefaultEndpointsProtocol=https;AccountName={name};"
     + "AccountKey={key};EndpointSuffix={core.windows.net}";
 QueueServiceAsyncClient client = new QueueServiceClientBuilder()
     .connectionString(connectionString)
     .buildAsyncClient();

コンストラクターの概要

コンストラクター 説明
QueueServiceClientBuilder()

QueueServiceAsyncClientを構成および構築QueueServiceClientできるビルダー インスタンスを作成します。

メソッドの概要

修飾子と型 メソッドと説明
QueueServiceClientBuilder addPolicy(HttpPipelinePolicy pipelinePolicy)

HttpPipelinePolicy送信された各要求に適用する を追加します。

QueueServiceAsyncClient buildAsyncClient()

ビルダーで設定された QueueServiceAsyncClient オプションに基づいて を作成します。

QueueServiceClient buildClient()

ビルダーで設定された QueueServiceClient オプションに基づいて を作成します。

QueueServiceClientBuilder clientOptions(ClientOptions clientOptions)

アプリケーション ID、ヘッダー、プロキシ構成などの共通プロパティを設定できます。

QueueServiceClientBuilder configuration(Configuration configuration)

クライアントのビルド中に環境構成値を取得するために使用する構成オブジェクトを設定します。

QueueServiceClientBuilder connectionString(String connectionString)

サービスに接続する接続文字列を設定します。

QueueServiceClientBuilder credential(AzureNamedKeyCredential credential)

サービスに AzureNamedKeyCredential 送信された要求を承認するために使用される を設定します。

QueueServiceClientBuilder credential(AzureSasCredential credential)

サービスに AzureSasCredential 送信された要求を承認するために使用される を設定します。

QueueServiceClientBuilder credential(TokenCredential credential)

サービスに TokenCredential 送信された要求を承認するために使用される を設定します。

QueueServiceClientBuilder credential(StorageSharedKeyCredential credential)

サービスに StorageSharedKeyCredential 送信された要求を承認するために使用される を設定します。

QueueServiceClientBuilder endpoint(String endpoint)

クライアントが対話する Azure Storage Queue インスタンスのエンドポイントを設定します。

static HttpLogOptions getDefaultHttpLogOptions()

既定のストレージ 許可リスト のログ ヘッダーとクエリ パラメーターを取得します。

QueueServiceClientBuilder httpClient(HttpClient httpClient)

サービスとの間で HttpClient 要求を送受信するために使用する を設定します。

QueueServiceClientBuilder httpLogOptions(HttpLogOptions logOptions)

サービスとの間で HttpLogOptions 要求を送受信するときに使用する を設定します。

QueueServiceClientBuilder messageEncoding(QueueMessageEncoding messageEncoding)

キュー メッセージのエンコードを設定します。

QueueServiceClientBuilder pipeline(HttpPipeline httpPipeline)

HttpPipelineサービス クライアントに使用する を設定します。

QueueServiceClientBuilder processMessageDecodingError(Consumer<QueueMessageDecodingError> processMessageDecodingErrorHandler)

キューからメッセージを受信またはピークしたときに必要なタスクを実行するハンドラーを設定しますが、デコードできません。

QueueServiceClientBuilder processMessageDecodingErrorAsync(Function<QueueMessageDecodingError,Mono<Void>> processMessageDecodingErrorAsyncHandler)

メッセージの受信時またはキューからのピーク時に必要なタスクを実行する非同期ハンドラーを設定しますが、デコードできません。

QueueServiceClientBuilder retryOptions(RetryOptions retryOptions)

クライアントを RetryOptions 介して行われたすべての要求の を設定します。

QueueServiceClientBuilder retryOptions(RequestRetryOptions retryOptions)

クライアントを介して行われたすべての要求の要求再試行オプションを設定します。

QueueServiceClientBuilder sasToken(String sasToken)

サービスに送信される要求を承認するために使用する SAS トークンを設定します。

QueueServiceClientBuilder serviceVersion(QueueServiceVersion version)

API 要求を QueueServiceVersion 行うときに使用する を設定します。

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

コンストラクターの詳細

QueueServiceClientBuilder

public QueueServiceClientBuilder()

QueueServiceAsyncClientを構成および構築QueueServiceClientできるビルダー インスタンスを作成します。

メソッドの詳細

addPolicy

public QueueServiceClientBuilder addPolicy(HttpPipelinePolicy pipelinePolicy)

HttpPipelinePolicy送信された各要求に適用する を追加します。

メモ: HttpTrait API の優先順位を理解することが重要です。 特に、 が指定されている場合 HttpPipeline 、これは特性内の他のすべての API よりも優先され、無視されます。 が指定されていない HttpPipeline 場合、HTTP パイプラインは、この特性に指定された設定に基づいて内部的に構築されます。 また、 が指定されている場合も無視される、この特性を実装する型には他の API が存在する可能性 HttpPipeline があるため、この特性を実装する型のドキュメントを必ず参照して、影響の完全なセットを理解してください。

Parameters:

pipelinePolicy - HttpPipelinePolicy

Returns:

更新された QueueServiceClientBuilder オブジェクト

buildAsyncClient

public QueueServiceAsyncClient buildAsyncClient()

ビルダーで設定された QueueServiceAsyncClient オプションに基づいて を作成します。 これがの新しいインスタンス QueueServiceAsyncClient と呼ばれるたびにが作成されます。

が設定されている場合pipeline(HttpPipeline httpPipeline)は、 と endpoint(String endpoint)pipeline を使用して を作成しますQueueServiceAsyncClient。 その他のビルダー設定はすべて無視されます。

Returns:

ビルダーから設定されたオプションを含む QueueServiceAsyncClient。

buildClient

public QueueServiceClient buildClient()

ビルダーで設定された QueueServiceClient オプションに基づいて を作成します。 これがの新しいインスタンス QueueServiceClient と呼ばれるたびにが作成されます。

が設定されている場合pipeline(HttpPipeline httpPipeline)は、 と endpoint(String endpoint)pipeline を使用して を作成しますQueueServiceClient。 その他のビルダー設定はすべて無視されます。

Returns:

ビルダーから設定されたオプションを含む QueueServiceClient。

clientOptions

public QueueServiceClientBuilder clientOptions(ClientOptions clientOptions)

アプリケーション ID、ヘッダー、プロキシ構成などの共通プロパティを設定できます。このメソッドは、 クラスのインスタンス (基底クラスの HttpClientOptions サブクラス ClientOptions ) で呼び出することをお勧めします。 HttpClientOptions サブクラスは、HTTP クライアントに適した構成オプションをさらに提供します。これは、この HttpTrait インターフェイスを実装するすべてのクラスに適用できます。

メモ: HttpTrait API の優先順位を理解することが重要です。 特に、 が指定されている場合 HttpPipeline 、これは特性内の他のすべての API よりも優先され、無視されます。 が指定されていない HttpPipeline 場合、HTTP パイプラインは、この特性に指定された設定に基づいて内部的に構築されます。 また、 が指定されている場合も無視される、この特性を実装する型には他の API が存在する可能性 HttpPipeline があるため、この特性を実装する型のドキュメントを必ず参照して、影響の完全なセットを理解してください。

Parameters:

clientOptions - の構成済みインスタンス HttpClientOptions

Returns:

更新された QueueServiceClientBuilder オブジェクト

configuration

public QueueServiceClientBuilder configuration(Configuration configuration)

クライアントのビルド中に環境構成値を取得するために使用する構成オブジェクトを設定します。

Parameters:

configuration - 環境構成の取得に使用される構成ストア。

Returns:

更新された QueueServiceClientBuilder オブジェクト

connectionString

public QueueServiceClientBuilder connectionString(String connectionString)

サービスに接続する接続文字列を設定します。

Parameters:

connectionString - ストレージ アカウントの接続文字列。

Returns:

更新された QueueServiceClientBuilder

credential

public QueueServiceClientBuilder credential(AzureNamedKeyCredential credential)

サービスに AzureNamedKeyCredential 送信された要求を承認するために使用される を設定します。

Parameters:

credential - AzureNamedKeyCredential.

Returns:

更新された QueueServiceClientBuilder

credential

public QueueServiceClientBuilder credential(AzureSasCredential credential)

サービスに AzureSasCredential 送信された要求を承認するために使用される を設定します。

Parameters:

credential - AzureSasCredential サービスに送信された要求を承認するために使用されます。

Returns:

更新された QueueServiceClientBuilder

credential

public QueueServiceClientBuilder credential(TokenCredential credential)

サービスに TokenCredential 送信された要求を承認するために使用される を設定します。 型の適切な使用方法の詳細については、Azure SDK for Java の ID と認証 に関するドキュメントを TokenCredential 参照してください。

Parameters:

credential - TokenCredential サービスに送信された要求を承認するために使用されます。

Returns:

更新された QueueServiceClientBuilder

credential

public QueueServiceClientBuilder credential(StorageSharedKeyCredential credential)

サービスに StorageSharedKeyCredential 送信された要求を承認するために使用される を設定します。

Parameters:

Returns:

更新された QueueServiceClientBuilder

endpoint

public QueueServiceClientBuilder endpoint(String endpoint)

クライアントが対話する Azure Storage Queue インスタンスのエンドポイントを設定します。

エンドポイントのクエリ パラメーターは、サービスに送信された要求を認証するための SAS トークンを生成しようとして解析されます。

Parameters:

endpoint - サービス要求の送受信元となる Azure Storage Queue インスタンスの URL。

Returns:

更新された QueueServiceClientBuilder オブジェクト

getDefaultHttpLogOptions

public static HttpLogOptions getDefaultHttpLogOptions()

既定のストレージ 許可リスト のログ ヘッダーとクエリ パラメーターを取得します。

Returns:

既定の http ログ オプション。

httpClient

public QueueServiceClientBuilder httpClient(HttpClient httpClient)

サービスとの間で HttpClient 要求を送受信するために使用する を設定します。

メモ: HttpTrait API の優先順位を理解することが重要です。 特に、 が指定されている場合 HttpPipeline 、これは特性内の他のすべての API よりも優先され、無視されます。 が指定されていない HttpPipeline 場合、HTTP パイプラインは、この特性に指定された設定に基づいて内部的に構築されます。 また、 が指定されている場合も無視される、この特性を実装する型には他の API が存在する可能性 HttpPipeline があるため、この特性を実装する型のドキュメントを必ず参照して、影響の完全なセットを理解してください。

Parameters:

httpClient - HttpClient要求に使用する 。

Returns:

更新された QueueServiceClientBuilder オブジェクト

httpLogOptions

public QueueServiceClientBuilder httpLogOptions(HttpLogOptions logOptions)

サービスとの間で HttpLogOptions 要求を送受信するときに使用する を設定します。 が logLevel 指定されていない場合は、 の HttpLogDetailLevel#NONE 既定値が設定されます。

メモ: HttpTrait API の優先順位を理解することが重要です。 特に、 が指定されている場合 HttpPipeline 、これは特性内の他のすべての API よりも優先され、無視されます。 が指定されていない HttpPipeline 場合、HTTP パイプラインは、この特性に指定された設定に基づいて内部的に構築されます。 また、 が指定されている場合も無視される、この特性を実装する型には他の API が存在する可能性 HttpPipeline があるため、この特性を実装する型のドキュメントを必ず参照して、影響の完全なセットを理解してください。

Parameters:

logOptions - HttpLogOptionsサービスとの間で要求を送受信するときに使用する 。

Returns:

更新された QueueServiceClientBuilder オブジェクト

messageEncoding

public QueueServiceClientBuilder messageEncoding(QueueMessageEncoding messageEncoding)

キュー メッセージのエンコードを設定します。

Parameters:

messageEncoding - QueueMessageEncoding.

Returns:

更新された QueueServiceClientBuilder オブジェクト

pipeline

public QueueServiceClientBuilder pipeline(HttpPipeline httpPipeline)

HttpPipelineサービス クライアントに使用する を設定します。

メモ: HttpTrait API の優先順位を理解することが重要です。 特に、 が指定されている場合 HttpPipeline 、これは特性内の他のすべての API よりも優先され、無視されます。 が指定されていない HttpPipeline 場合、HTTP パイプラインは、この特性に指定された設定に基づいて内部的に構築されます。 また、 が指定されている場合も無視される、この特性を実装する型には他の API が存在する可能性 HttpPipeline があるため、この特性を実装する型のドキュメントを必ず参照して、影響の完全なセットを理解してください。

endpoint(String endpoint)が設定されている場合pipeline、 は無視されません。

Parameters:

httpPipeline - HttpPipeline を使用してサービス要求を送信し、応答を受信します。

Returns:

更新された QueueServiceClientBuilder オブジェクト

processMessageDecodingError

public QueueServiceClientBuilder processMessageDecodingError(Consumer processMessageDecodingErrorHandler)

キューからメッセージを受信またはピークしたときに必要なタスクを実行するハンドラーを設定しますが、デコードできません。

キューが特定 QueueMessageEncoding のメッセージを予期しているが、メッセージを予期した方法でエンコードしていない別のプロデューサーがある場合は、このようなメッセージを受信またはピークにできます。 つまり、キューにはエンコードが異なるメッセージが含まれています。

QueueMessageDecodingErrorQueueClientには、メッセージgetQueueMessageItem()getPeekedMessageItem()を受信したキューおよび未加工の本文を含むキューが含まれます。つまり、キューから受信された本文を検査できるようにデコードは試行されません。

ハンドラーは、キューからメッセージを削除しようとしません。 したがって、このような処理はハンドラー自体に含める必要があります。

ハンドラーは、このビルダーから作成 QueueServiceClient または QueueServiceAsyncClient ビルドされたすべてのキュー クライアントによって共有されます。

このハンドラーは同期 QueueClientに使用することをお勧めします。

コード サンプル

String connectionString = "DefaultEndpointsProtocol=https;AccountName={name};"
     + "AccountKey={key};EndpointSuffix={core.windows.net}";

 Consumer<QueueMessageDecodingError> processMessageDecodingErrorHandler =
     (queueMessageDecodingFailure) -> {
         QueueMessageItem queueMessageItem = queueMessageDecodingFailure.getQueueMessageItem();
         PeekedMessageItem peekedMessageItem = queueMessageDecodingFailure.getPeekedMessageItem();
         if (queueMessageItem != null) {
             System.out.printf("Received badly encoded message, messageId=%s, messageBody=%s",
                 queueMessageItem.getMessageId(),
                 queueMessageItem.getBody().toString());
             queueMessageDecodingFailure
                 .getQueueClient()
                 .deleteMessage(queueMessageItem.getMessageId(), queueMessageItem.getPopReceipt());
         } else if (peekedMessageItem != null) {
             System.out.printf("Peeked badly encoded message, messageId=%s, messageBody=%s",
                 peekedMessageItem.getMessageId(),
                 peekedMessageItem.getBody().toString());
         }
     };

 QueueServiceClient client = new QueueServiceClientBuilder()
     .connectionString(connectionString)
     .processMessageDecodingError(processMessageDecodingErrorHandler)
     .buildClient();

Parameters:

processMessageDecodingErrorHandler - ハンドラー。

Returns:

更新された QueueServiceClientBuilder オブジェクト

processMessageDecodingErrorAsync

public QueueServiceClientBuilder processMessageDecodingErrorAsync(Function> processMessageDecodingErrorAsyncHandler)

メッセージの受信時またはキューからのピーク時に必要なタスクを実行する非同期ハンドラーを設定しますが、デコードできません。

キューが特定 QueueMessageEncoding のメッセージを予期しているが、メッセージを予期した方法でエンコードしていない別のプロデューサーがある場合は、このようなメッセージを受信またはピークにできます。 つまり、キューにはエンコードが異なるメッセージが含まれています。

QueueMessageDecodingErrorQueueAsyncClientには、メッセージgetQueueMessageItem()getPeekedMessageItem()を受信したキューおよび未加工の本文を含むキューが含まれます。つまり、キューから受信された本文を検査できるようにデコードは試行されません。

ハンドラーは、キューからメッセージを削除しようとしません。 したがって、このような処理はハンドラー自体に含める必要があります。

ハンドラーは、このビルダーから作成 QueueServiceClient または QueueServiceAsyncClient ビルドされたすべてのキュー クライアントによって共有されます。

このハンドラーは非同期 QueueAsyncClientに使用することをお勧めします。

コード サンプル

String connectionString = "DefaultEndpointsProtocol=https;AccountName={name};"
     + "AccountKey={key};EndpointSuffix={core.windows.net}";

 Function<QueueMessageDecodingError, Mono<Void>> processMessageDecodingErrorHandler =
     (queueMessageDecodingFailure) -> {
         QueueMessageItem queueMessageItem = queueMessageDecodingFailure.getQueueMessageItem();
         PeekedMessageItem peekedMessageItem = queueMessageDecodingFailure.getPeekedMessageItem();
         if (queueMessageItem != null) {
             System.out.printf("Received badly encoded message, messageId=%s, messageBody=%s",
                 queueMessageItem.getMessageId(),
                 queueMessageItem.getBody().toString());
             return queueMessageDecodingFailure
                 .getQueueAsyncClient()
                 .deleteMessage(queueMessageItem.getMessageId(), queueMessageItem.getPopReceipt());
         } else if (peekedMessageItem != null) {
             System.out.printf("Peeked badly encoded message, messageId=%s, messageBody=%s",
                 peekedMessageItem.getMessageId(),
                 peekedMessageItem.getBody().toString());
             return Mono.empty();
         } else {
             return Mono.empty();
         }
     };

 QueueServiceClient client = new QueueServiceClientBuilder()
     .connectionString(connectionString)
     .processMessageDecodingErrorAsync(processMessageDecodingErrorHandler)
     .buildClient();

Parameters:

processMessageDecodingErrorAsyncHandler - ハンドラー。

Returns:

更新された QueueServiceClientBuilder オブジェクト

retryOptions

public QueueServiceClientBuilder retryOptions(RetryOptions retryOptions)

クライアントを RetryOptions 介して行われたすべての要求の を設定します。

メモ: HttpTrait API の優先順位を理解することが重要です。 特に、 が指定されている場合 HttpPipeline 、これは特性内の他のすべての API よりも優先され、無視されます。 が指定されていない HttpPipeline 場合、HTTP パイプラインは、この特性に指定された設定に基づいて内部的に構築されます。 また、 が指定されている場合も無視される、この特性を実装する型には他の API が存在する可能性 HttpPipeline があるため、この特性を実装する型のドキュメントを必ず参照して、影響の完全なセットを理解してください。

この設定は、 を使用する場合 retryOptions(RequestRetryOptions retryOptions)と相互に排他的です。 を使用して retryOptions(RequestRetryOptions retryOptions) 、ストレージ固有のオプションも設定することを検討してください。

Parameters:

retryOptions - RetryOptionsクライアントを介して行われたすべての要求に使用する 。

Returns:

更新された QueueServiceClientBuilder オブジェクト

retryOptions

public QueueServiceClientBuilder retryOptions(RequestRetryOptions retryOptions)

クライアントを介して行われたすべての要求の要求再試行オプションを設定します。 この設定は、 を使用する場合 retryOptions(RetryOptions retryOptions)と相互に排他的です。

Parameters:

retryOptions - RequestRetryOptions.

Returns:

更新された QueueServiceClientBuilder オブジェクト。

sasToken

public QueueServiceClientBuilder sasToken(String sasToken)

サービスに送信される要求を承認するために使用する SAS トークンを設定します。

Parameters:

sasToken - 要求の認証に使用する SAS トークン。 この文字列は、完全な URL ではなく、クエリ パラメーター (先頭の '?' の有無にかかわらず) のみを指定する必要があります。

Returns:

更新された QueueServiceClientBuilder

serviceVersion

public QueueServiceClientBuilder serviceVersion(QueueServiceVersion version)

API 要求を QueueServiceVersion 行うときに使用する を設定します。

サービス バージョンが指定されていない場合、使用されるサービス バージョンは、使用されているクライアント ライブラリのバージョンに基づく最新の既知のサービス バージョンになります。 サービス バージョンが指定されていない場合、新しいバージョンのクライアント ライブラリに更新すると、新しいサービス バージョンに移行する可能性があります。

特定のサービス バージョンを対象とすると、サービスから新しい API のエラーが返される可能性もあります。

Parameters:

version - QueueServiceVersion 要求を行うときに使用するサービスの。

Returns:

更新された QueueServiceClientBuilder オブジェクト

適用対象