public final class WebPubSubClientBuilder extends Object
sync
and async
Azure Web Pub Sub clients, using the
buildClient
and buildAsyncClient
methods respectively.
To fully configure a Azure Web Pub Sub client, it is necessary to supply a
connection string
retrieved from the Azure Portal, or else a combination of
credential
and endpoint
.
An Azure Web Pub Sub client is required to connect to a specific hub
. An exception will be
thrown when the build methods are called if the hub value is null or an empty String.
Code Samples
WebPubSubAsyncServiceClient client = new WebPubSubClientBuilder() .connectionString("<Insert connection string from Azure Portal>") .buildAsyncClient();
This demonstrates using the connection string provided by the Azure Portal. Another approach is to use the combination of credential and endpoint details, as shown below:
WebPubSubAsyncServiceClient client = new WebPubSubClientBuilder() .credential(new AzureKeyCredential("<Insert key from Azure Portal>")) .endpoint("<Insert endpoint from Azure Portal>") .buildAsyncClient();
Of course, synchronous clients may also be instantiated, by calling buildClient
rather than
buildAsyncClient
.
WebPubSubServiceClient client = new WebPubSubClientBuilder() .connectionString("<Insert connection string from Azure Portal>") .buildClient();
Constructor and Description |
---|
WebPubSubClientBuilder()
Creates a new builder instance with all values set to their default value.
|
Modifier and Type | Method and Description |
---|---|
WebPubSubClientBuilder |
addPolicy(com.azure.core.http.policy.HttpPipelinePolicy policy)
Adds a policy to the set of existing policies that are executed after required policies.
|
WebPubSubAsyncServiceClient |
buildAsyncClient()
Builds an instance of WebPubSubAsyncServiceClient with the provided parameters.
|
WebPubSubServiceClient |
buildClient()
Builds an instance of WebPubSubServiceClient with the provided parameters.
|
WebPubSubClientBuilder |
clientOptions(com.azure.core.util.ClientOptions clientOptions)
Sets the
ClientOptions which enables various options to be set on the client. |
WebPubSubClientBuilder |
configuration(com.azure.core.util.Configuration configuration)
Sets the configuration store that is used during construction of the service client.
|
WebPubSubClientBuilder |
connectionString(String connectionString)
Sets the credential to use when authenticating HTTP requests.
|
WebPubSubClientBuilder |
credential(com.azure.core.credential.AzureKeyCredential credential)
Sets the
AzureKeyCredential used to authenticate HTTP requests. |
WebPubSubClientBuilder |
endpoint(String endpoint)
Sets the service endpoint for the Azure Web Pub Sub instance.
|
WebPubSubClientBuilder |
httpClient(com.azure.core.http.HttpClient client)
Sets the HTTP client to use for sending and receiving requests to and from the service.
|
WebPubSubClientBuilder |
httpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions)
Sets the logging configuration for HTTP requests and responses.
|
WebPubSubClientBuilder |
hub(String hub)
Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or
underscore.
|
WebPubSubClientBuilder |
pipeline(com.azure.core.http.HttpPipeline pipeline)
Sets the HTTP pipeline to use for the service client.
|
WebPubSubClientBuilder |
retryPolicy(com.azure.core.http.policy.RetryPolicy retryPolicy)
Sets the
HttpPipelinePolicy that is used when each request is sent. |
WebPubSubClientBuilder |
serviceVersion(WebPubSubServiceVersion version)
Sets the
WebPubSubServiceVersion that is used when making API requests. |
public WebPubSubClientBuilder()
public WebPubSubClientBuilder clientOptions(com.azure.core.util.ClientOptions clientOptions)
ClientOptions
which enables various options to be set on the client. For example setting an
applicationId
using ClientOptions.setApplicationId(String)
to configure
the UserAgentPolicy
for telemetry/monitoring purposes.
More About Azure Core: Telemetry policy
clientOptions
- the ClientOptions
to be set on the client.public WebPubSubClientBuilder connectionString(String connectionString)
connectionString
- Connection string in the format "endpoint={endpoint_value};accesskey={accesskey_value}"NullPointerException
- If connectionString
is null
.public WebPubSubClientBuilder endpoint(String endpoint)
endpoint
- The URL of the Azure Web Pub Sub instance to send service requests to, and receive responses
from.IllegalArgumentException
- if endpoint
is null
.public WebPubSubClientBuilder credential(com.azure.core.credential.AzureKeyCredential credential)
AzureKeyCredential
used to authenticate HTTP requests.credential
- AzureKeyCredential used to authenticate HTTP requests.NullPointerException
- If credential
is null
.public WebPubSubClientBuilder hub(String hub)
hub
- Target hub name, which should start with alphabetic characters and only contain alpha-numeric
characters or underscore.NullPointerException
- If hub
is null
.public WebPubSubClientBuilder httpLogOptions(com.azure.core.http.policy.HttpLogOptions logOptions)
If logLevel is not provided, default value of HttpLogDetailLevel.NONE
is
set.
logOptions
- The logging configuration to use when sending and receiving HTTP requests/responses.public WebPubSubClientBuilder addPolicy(com.azure.core.http.policy.HttpPipelinePolicy policy)
policy
- The retry policy for service requests.NullPointerException
- If policy
is null
.public WebPubSubClientBuilder httpClient(com.azure.core.http.HttpClient client)
client
- The HTTP client to use for requests.public WebPubSubClientBuilder pipeline(com.azure.core.http.HttpPipeline pipeline)
pipeline
is set, all other settings are ignored, aside from
connectionString
to build WebPubSubAsyncServiceClient
or
WebPubSubServiceClient
.pipeline
- The HTTP pipeline to use for sending service requests and receiving responses.public WebPubSubClientBuilder configuration(com.azure.core.util.Configuration configuration)
global
configuration store
, use Configuration.NONE
to bypass using configuration settings during construction.configuration
- The configuration store used topublic WebPubSubClientBuilder retryPolicy(com.azure.core.http.policy.RetryPolicy retryPolicy)
HttpPipelinePolicy
that is used when each request is sent. The default retry policy will be
used if not provided.retryPolicy
- user's retry policy applied to each request.public WebPubSubClientBuilder serviceVersion(WebPubSubServiceVersion version)
WebPubSubServiceVersion
that is used when making API requests.
If a service version is not provided, the service version that will be used will be the latest known service version based on the version of the client library being used. If no service version is specified, updating to a newer version the client library will have the result of potentially moving to a newer service version.
version
- WebPubSubServiceVersion
of the service to be used when making requests.public WebPubSubAsyncServiceClient buildAsyncClient()
public WebPubSubServiceClient buildClient()
Copyright © 2021 Microsoft Corporation. All rights reserved.