public class ConnectionStringBuilder extends Object
Sample Code:
ConnectionStringBuilder connectionStringBuilder = new ConnectionStringBuilder(
"ServiceBusNamespaceName",
"ServiceBusEntityName", // QueueName or TopicName or SubscriptionPath
"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:
Modifier and Type | Field and Description |
---|---|
static Duration |
DefaultOperationTimeout
Default operation timeout if timeout is not specified in the connection string.
|
Constructor and Description |
---|
ConnectionStringBuilder(String connectionString)
Creates a new instance from the given connection string.
|
ConnectionStringBuilder(String namespaceConnectionString,
String entityPath)
Creates a new instance from the given connection string and entity path.
|
ConnectionStringBuilder(String namespaceName,
String entityPath,
String sharedAccessSingature)
Creates a new instance from namespace, entity path and already generated SAS token.
|
ConnectionStringBuilder(String namespaceName,
String entityPath,
String sharedAccessKeyName,
String sharedAccessKey)
Creates a new instance from namespace, entity path and SAS Key name and value.
|
ConnectionStringBuilder(URI endpointAddress,
String entityPath,
String sharedAccessSingature)
Creates a new instance from endpoint address of the namesapce, entity path and already generated SAS token.
|
ConnectionStringBuilder(URI endpointAddress,
String entityPath,
String sharedAccessKeyName,
String sharedAccessKey)
Creates a new instance from endpoint address of the namesapce, entity path and SAS Key name and value
|
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()
Gets the duration after which a pending operation like SEND or RECEIVE will time out.
|
RetryPolicy |
getRetryPolicy()
Get the retry policy instance that was created as part of this builder's creation.
|
String |
getSasKey()
Get the shared access policy key value from the connection string or null.
|
String |
getSasKeyName()
Get the shared access policy owner name from the connection string or null.
|
String |
getSharedAccessSignatureToken()
Returns the shared access signature token from the connection string or null.
|
void |
setOperationTimeout(Duration operationTimeout)
Set the OperationTimeout value in the Connection String.
|
void |
setRetryPolicy(RetryPolicy retryPolicy)
Set the retry policy.
|
String |
toLoggableString() |
String |
toString()
Returns an inter-operable connection string that can be used to connect to ServiceBus Namespace
|
public static final Duration DefaultOperationTimeout
public ConnectionStringBuilder(String namespaceName, String entityPath, String sharedAccessKeyName, String sharedAccessKey)
namespaceName
- Namespace name (dns suffix - ex: .servicebus.windows.net is not required)entityPath
- Entity path. For queue or topic, use name. For subscription use <topicName>/subscriptions/<subscriptionName>sharedAccessKeyName
- Shared Access Key namesharedAccessKey
- Shared Access Keypublic ConnectionStringBuilder(String namespaceName, String entityPath, String sharedAccessSingature)
namespaceName
- Namespace name (dns suffix - ex: .servicebus.windows.net is not required)entityPath
- Entity path. For queue or topic, use name. For subscription use <topicName>/subscriptions/<subscriptionName>sharedAccessSingature
- Shared Access Signature already generatedpublic ConnectionStringBuilder(URI endpointAddress, String entityPath, String sharedAccessKeyName, String sharedAccessKey)
endpointAddress
- namespace level endpoint. This needs to be in the format of scheme://fullyQualifiedServiceBusNamespaceEndpointNameentityPath
- Entity path. For queue or topic, use name. For subscription use <topicName>/subscriptions/<subscriptionName>sharedAccessKeyName
- Shared Access Key namesharedAccessKey
- Shared Access Keypublic ConnectionStringBuilder(URI endpointAddress, String entityPath, String sharedAccessSingature)
endpointAddress
- namespace level endpoint. This needs to be in the format of scheme://fullyQualifiedServiceBusNamespaceEndpointNameentityPath
- Entity path. For queue or topic, use name. For subscription use <topicName>/subscriptions/<subscriptionName>sharedAccessSingature
- Shared Access Signature already generatedpublic ConnectionStringBuilder(String connectionString)
connectionString
- ServiceBus ConnectionStringIllegalConnectionStringFormatException
- when the format of the ConnectionString is not validpublic ConnectionStringBuilder(String namespaceConnectionString, String entityPath)
namespaceConnectionString
- connections string of the ServiceBus namespace. This doesn't include the entity path.entityPath
- path to the entity within the namespacepublic URI getEndpoint()
public String getSasKey()
public String getSasKeyName()
public String getSharedAccessSignatureToken()
public String getEntityPath()
public Duration getOperationTimeout()
DefaultOperationTimeout
This value will be used by all operations which uses this ConnectionStringBuilder
, unless explicitly over-ridden.public 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 Timeoutpublic RetryPolicy getRetryPolicy()
public void setRetryPolicy(RetryPolicy retryPolicy)
RetryPolicy is not Serialized as part of toString()
and is not interoperable with ServiceBus clients in other platforms.
retryPolicy
- RetryPolicy applied for any operation performed using this ConnectionStringpublic String toString()
public String toLoggableString()
Copyright © 2018. All rights reserved.