QueueServiceClientBuilder クラス
- java.
lang. Object - com.
azure. storage. queue. QueueServiceClientBuilder
- com.
実装
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できるビルダー インスタンスを作成します。 |
メソッドの概要
メソッドの継承元: java.lang.Object
コンストラクターの詳細
QueueServiceClientBuilder
public QueueServiceClientBuilder()
と QueueServiceAsyncClientを構成および構築QueueServiceClientできるビルダー インスタンスを作成します。
メソッドの詳細
addPolicy
public QueueServiceClientBuilder addPolicy(HttpPipelinePolicy pipelinePolicy)
HttpPipelinePolicy送信された各要求に適用する を追加します。
メモ: HttpTrait API の優先順位を理解することが重要です。 特に、 が指定されている場合 HttpPipeline 、これは特性内の他のすべての API よりも優先され、無視されます。 が指定されていない HttpPipeline 場合、HTTP パイプラインは、この特性に指定された設定に基づいて内部的に構築されます。 また、 が指定されている場合も無視される、この特性を実装する型には他の API が存在する可能性 HttpPipeline があるため、この特性を実装する型のドキュメントを必ず参照して、影響の完全なセットを理解してください。
Parameters:
Returns:
buildAsyncClient
public QueueServiceAsyncClient buildAsyncClient()
ビルダーで設定された QueueServiceAsyncClient オプションに基づいて を作成します。 これがの新しいインスタンス QueueServiceAsyncClient と呼ばれるたびにが作成されます。
が設定されている場合pipeline(HttpPipeline httpPipeline)は、 と endpoint(String endpoint)pipeline
を使用して を作成しますQueueServiceAsyncClient。 その他のビルダー設定はすべて無視されます。
Returns:
buildClient
public QueueServiceClient buildClient()
ビルダーで設定された QueueServiceClient オプションに基づいて を作成します。 これがの新しいインスタンス QueueServiceClient と呼ばれるたびにが作成されます。
が設定されている場合pipeline(HttpPipeline httpPipeline)は、 と endpoint(String endpoint)pipeline
を使用して を作成しますQueueServiceClient。 その他のビルダー設定はすべて無視されます。
Returns:
clientOptions
public QueueServiceClientBuilder clientOptions(ClientOptions clientOptions)
アプリケーション ID、ヘッダー、プロキシ構成などの共通プロパティを設定できます。このメソッドは、 クラスのインスタンス (基底クラスの HttpClientOptions サブクラス ClientOptions ) で呼び出することをお勧めします。 HttpClientOptions サブクラスは、HTTP クライアントに適した構成オプションをさらに提供します。これは、この HttpTrait インターフェイスを実装するすべてのクラスに適用できます。
メモ: HttpTrait API の優先順位を理解することが重要です。 特に、 が指定されている場合 HttpPipeline 、これは特性内の他のすべての API よりも優先され、無視されます。 が指定されていない HttpPipeline 場合、HTTP パイプラインは、この特性に指定された設定に基づいて内部的に構築されます。 また、 が指定されている場合も無視される、この特性を実装する型には他の API が存在する可能性 HttpPipeline があるため、この特性を実装する型のドキュメントを必ず参照して、影響の完全なセットを理解してください。
Parameters:
Returns:
configuration
public QueueServiceClientBuilder configuration(Configuration configuration)
クライアントのビルド中に環境構成値を取得するために使用する構成オブジェクトを設定します。
Parameters:
Returns:
connectionString
public QueueServiceClientBuilder connectionString(String connectionString)
サービスに接続する接続文字列を設定します。
Parameters:
Returns:
credential
public QueueServiceClientBuilder credential(AzureNamedKeyCredential credential)
サービスに AzureNamedKeyCredential 送信された要求を承認するために使用される を設定します。
Parameters:
Returns:
credential
public QueueServiceClientBuilder credential(AzureSasCredential credential)
サービスに AzureSasCredential 送信された要求を承認するために使用される を設定します。
Parameters:
Returns:
credential
public QueueServiceClientBuilder credential(TokenCredential credential)
サービスに TokenCredential 送信された要求を承認するために使用される を設定します。 型の適切な使用方法の詳細については、Azure SDK for Java の ID と認証 に関するドキュメントを TokenCredential 参照してください。
Parameters:
Returns:
credential
public QueueServiceClientBuilder credential(StorageSharedKeyCredential credential)
サービスに StorageSharedKeyCredential 送信された要求を承認するために使用される を設定します。
Parameters:
Returns:
endpoint
public QueueServiceClientBuilder endpoint(String endpoint)
クライアントが対話する Azure Storage Queue インスタンスのエンドポイントを設定します。
エンドポイントのクエリ パラメーターは、サービスに送信された要求を認証するための SAS トークンを生成しようとして解析されます。
Parameters:
Returns:
getDefaultHttpLogOptions
public static HttpLogOptions getDefaultHttpLogOptions()
既定のストレージ 許可リスト のログ ヘッダーとクエリ パラメーターを取得します。
Returns:
httpClient
public QueueServiceClientBuilder httpClient(HttpClient httpClient)
サービスとの間で HttpClient 要求を送受信するために使用する を設定します。
メモ: HttpTrait API の優先順位を理解することが重要です。 特に、 が指定されている場合 HttpPipeline 、これは特性内の他のすべての API よりも優先され、無視されます。 が指定されていない HttpPipeline 場合、HTTP パイプラインは、この特性に指定された設定に基づいて内部的に構築されます。 また、 が指定されている場合も無視される、この特性を実装する型には他の API が存在する可能性 HttpPipeline があるため、この特性を実装する型のドキュメントを必ず参照して、影響の完全なセットを理解してください。
Parameters:
Returns:
httpLogOptions
public QueueServiceClientBuilder httpLogOptions(HttpLogOptions logOptions)
サービスとの間で HttpLogOptions 要求を送受信するときに使用する を設定します。 が logLevel
指定されていない場合は、 の HttpLogDetailLevel#NONE 既定値が設定されます。
メモ: HttpTrait API の優先順位を理解することが重要です。 特に、 が指定されている場合 HttpPipeline 、これは特性内の他のすべての API よりも優先され、無視されます。 が指定されていない HttpPipeline 場合、HTTP パイプラインは、この特性に指定された設定に基づいて内部的に構築されます。 また、 が指定されている場合も無視される、この特性を実装する型には他の API が存在する可能性 HttpPipeline があるため、この特性を実装する型のドキュメントを必ず参照して、影響の完全なセットを理解してください。
Parameters:
Returns:
messageEncoding
public QueueServiceClientBuilder messageEncoding(QueueMessageEncoding messageEncoding)
キュー メッセージのエンコードを設定します。
Parameters:
Returns:
pipeline
public QueueServiceClientBuilder pipeline(HttpPipeline httpPipeline)
HttpPipelineサービス クライアントに使用する を設定します。
メモ: HttpTrait API の優先順位を理解することが重要です。 特に、 が指定されている場合 HttpPipeline 、これは特性内の他のすべての API よりも優先され、無視されます。 が指定されていない HttpPipeline 場合、HTTP パイプラインは、この特性に指定された設定に基づいて内部的に構築されます。 また、 が指定されている場合も無視される、この特性を実装する型には他の API が存在する可能性 HttpPipeline があるため、この特性を実装する型のドキュメントを必ず参照して、影響の完全なセットを理解してください。
endpoint(String endpoint)が設定されている場合pipeline
、 は無視されません。
Parameters:
Returns:
processMessageDecodingError
public QueueServiceClientBuilder processMessageDecodingError(Consumer
キューからメッセージを受信またはピークしたときに必要なタスクを実行するハンドラーを設定しますが、デコードできません。
キューが特定 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:
Returns:
processMessageDecodingErrorAsync
public QueueServiceClientBuilder processMessageDecodingErrorAsync(Function
メッセージの受信時またはキューからのピーク時に必要なタスクを実行する非同期ハンドラーを設定しますが、デコードできません。
キューが特定 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:
Returns:
retryOptions
public QueueServiceClientBuilder retryOptions(RetryOptions retryOptions)
クライアントを RetryOptions 介して行われたすべての要求の を設定します。
メモ: HttpTrait API の優先順位を理解することが重要です。 特に、 が指定されている場合 HttpPipeline 、これは特性内の他のすべての API よりも優先され、無視されます。 が指定されていない HttpPipeline 場合、HTTP パイプラインは、この特性に指定された設定に基づいて内部的に構築されます。 また、 が指定されている場合も無視される、この特性を実装する型には他の API が存在する可能性 HttpPipeline があるため、この特性を実装する型のドキュメントを必ず参照して、影響の完全なセットを理解してください。
この設定は、 を使用する場合 retryOptions(RequestRetryOptions retryOptions)と相互に排他的です。 を使用して retryOptions(RequestRetryOptions retryOptions) 、ストレージ固有のオプションも設定することを検討してください。
Parameters:
Returns:
retryOptions
public QueueServiceClientBuilder retryOptions(RequestRetryOptions retryOptions)
クライアントを介して行われたすべての要求の要求再試行オプションを設定します。 この設定は、 を使用する場合 retryOptions(RetryOptions retryOptions)と相互に排他的です。
Parameters:
Returns:
sasToken
public QueueServiceClientBuilder sasToken(String sasToken)
サービスに送信される要求を承認するために使用する SAS トークンを設定します。
Parameters:
Returns:
serviceVersion
public QueueServiceClientBuilder serviceVersion(QueueServiceVersion version)
API 要求を QueueServiceVersion 行うときに使用する を設定します。
サービス バージョンが指定されていない場合、使用されるサービス バージョンは、使用されているクライアント ライブラリのバージョンに基づく最新の既知のサービス バージョンになります。 サービス バージョンが指定されていない場合、新しいバージョンのクライアント ライブラリに更新すると、新しいサービス バージョンに移行する可能性があります。
特定のサービス バージョンを対象とすると、サービスから新しい API のエラーが返される可能性もあります。
Parameters:
Returns: