public class ConnectionStringBuilder extends Object
ConnectionStringBuilder can be used to construct a connection string which can establish communication with ServiceBus entities.
It can also be used to perform basic validation on an existing connection string.
Sample Code:
ConnectionStringBuilder connectionStringBuilder = new ConnectionStringBuilder(
"ServiceBusNamespaceName",
"ServiceBusEntityName", // eventHubName or QueueName or TopicName
"SharedAccessSignatureKeyName",
"SharedAccessSignatureKey");
String connectionString = connectionStringBuilder.toString();
A connection string is basically a string consisted of key-value pair separated by ";". Basic format is {<key>=<value>[;<key>=<value>]} where supported key name are as follow:
| Constructor and Description |
|---|
ConnectionStringBuilder(String connectionString)
ConnectionString format:
Endpoint=sb://namespace_DNS_Name;EntityPath=EVENT_HUB_NAME;SharedAccessKeyName=SHARED_ACCESS_KEY_NAME;SharedAccessKey=SHARED_ACCESS_KEY
|
ConnectionStringBuilder(String namespaceName,
String entityPath,
String sharedAccessKeyName,
String sharedAccessKey)
Build a connection string consumable by
EventHubClient.createFromConnectionString(String) |
ConnectionStringBuilder(URI endpointAddress,
String entityPath,
String sharedAccessSignature)
Build a connection string consumable by
EventHubClient.createFromConnectionString(String) |
ConnectionStringBuilder(URI endpointAddress,
String entityPath,
String sharedAccessKeyName,
String sharedAccessKey)
Build a connection string consumable by
EventHubClient.createFromConnectionString(String) |
| Modifier and Type | Method and Description |
|---|---|
URI |
getEndpoint()
Get the endpoint which can be used to connect to the ServiceBus Namespace
|
String |
getEntityPath()
Get the entity path value from the connection string
|
Duration |
getOperationTimeout()
OperationTimeout is applied in erroneous situations to notify the caller about the relevant
ServiceBusException |
RetryPolicy |
getRetryPolicy()
Deprecated.
|
String |
getSasKey()
Get the shared access policy key value from the connection string
|
String |
getSasKeyName()
Get the shared access policy owner name from the connection string
|
String |
getSharedAccessSignature()
Get the shared access signature (also referred as SAS Token) from the connection string
|
void |
setOperationTimeout(Duration operationTimeout)
Set the OperationTimeout value in the Connection String.
|
void |
setRetryPolicy(RetryPolicy retryPolicy)
Deprecated.
|
String |
toString()
Returns an inter-operable connection string that can be used to connect to ServiceBus Namespace
|
public ConnectionStringBuilder(String namespaceName, String entityPath, String sharedAccessKeyName, String sharedAccessKey)
EventHubClient.createFromConnectionString(String)namespaceName - Namespace name (dns suffix - ex: .servicebus.windows.net is not required)entityPath - Entity path. For eventHubs case specify - eventHub name.sharedAccessKeyName - Shared Access Key namesharedAccessKey - Shared Access Keypublic ConnectionStringBuilder(URI endpointAddress, String entityPath, String sharedAccessKeyName, String sharedAccessKey)
EventHubClient.createFromConnectionString(String)endpointAddress - namespace level endpoint. This needs to be in the format of scheme://fullyQualifiedServiceBusNamespaceEndpointNameentityPath - Entity path. For eventHubs case specify - eventHub name.sharedAccessKeyName - Shared Access Key namesharedAccessKey - Shared Access Keypublic ConnectionStringBuilder(URI endpointAddress, String entityPath, String sharedAccessSignature)
EventHubClient.createFromConnectionString(String)endpointAddress - namespace level endpoint. This needs to be in the format of scheme://fullyQualifiedServiceBusNamespaceEndpointNameentityPath - Entity path. For eventHubs case specify - eventHub name.sharedAccessSignature - Shared Access Signaturepublic ConnectionStringBuilder(String connectionString)
connectionString - ServiceBus ConnectionStringIllegalConnectionStringFormatException - when the format of the ConnectionString is not validpublic URI getEndpoint()
public String getSasKey()
public String getSasKeyName()
public String getSharedAccessSignature()
public String getEntityPath()
public Duration getOperationTimeout()
ServiceBusExceptionpublic void setOperationTimeout(Duration operationTimeout)
ConnectionStringBuilder, unless explicitly over-ridden.
ConnectionString with operationTimeout is not inter-operable between java and clients in other platforms.
operationTimeout - Operation Timeout@Deprecated public RetryPolicy getRetryPolicy()
@Deprecated public void setRetryPolicy(RetryPolicy retryPolicy)
RetryPolicy is not inter-operable with ServiceBus clients in other platforms.
retryPolicy - RetryPolicy applied for any operation performed using this ConnectionStringCopyright © 2017. All rights reserved.