ConnectionStringBuilder 类
定义
This class 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", // QueueName or TopicName or SubscriptionPath
"SharedAccessSignatureKeyName",
"SharedAccessSignatureKey");
String connectionString = connectionStringBuilder.toString();
</code></pre></p>
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:
Endpoint - URL that points to the servicebus namespace
EntityPath - Path to the service bus entity (queue/topic/subscription/). For queues and topics, it is just the entity name. For subscriptions, path is <topicName>/subscriptions/<subscriptionName>
SharedAccessKeyName - Key name to the corresponding shared access policy rule for the namespace, or entity.
SharedAccessKey - Key value for the corresponding shared access policy rule of the namespace or entity.
SharedAccessSignatureToken - Instead of a key name and key value, clients can provide an already generated SAS Token.
OperationTimeout - Default timeout to be used for all senders, receiver and clients created from this connection string.
RetryPolicy - Name of the retry policy.
public class ConnectionStringBuilder
- 继承
-
java.lang.ObjectConnectionStringBuilder
构造函数
ConnectionStringBuilder(final String namespaceName, final String entityPath, final String sharedAccessKeyName, final String sharedAccessKey) |
Creates a new instance from namespace, entity path and SAS Key name and value. |
ConnectionStringBuilder(final String namespaceName, final String entityPath, final String sharedAccessSingature) |
Creates a new instance from namespace, entity path and already generated SAS token. |
ConnectionStringBuilder(final URI endpointAddress, final String entityPath, final String sharedAccessKeyName, final String sharedAccessKey) |
Creates a new instance from endpoint address of the namesapce, entity path and SAS Key name and value |
ConnectionStringBuilder(final URI endpointAddress, final String entityPath, final String sharedAccessSingature) |
Creates a new instance from endpoint address of the namesapce, entity path and already generated SAS token. |
ConnectionStringBuilder(String connectionString) |
Creates a new instance from the given connection string. ConnectionString format: Endpoint=sb://namespace_DNS_Name;EntityPath=EVENT_HUB_NAME;SharedAccessKeyName=SHARED_ACCESS_KEY_NAME;SharedAccessKey=SHARED_ACCESS_KEY or Endpoint=sb://namespace_DNS_Name;EntityPath=EVENT_HUB_NAME;SharedAccessSignatureToken=SHARED_ACCESS_SIGNATURE_TOKEN |
ConnectionStringBuilder(String namespaceConnectionString, String entityPath) |
Creates a new instance from the given connection string and entity path. A connection string may or may not include the entity path. ConnectionString format: Endpoint=sb://namespace_DNS_Name;EntityPath=EVENT_HUB_NAME;SharedAccessKeyName=SHARED_ACCESS_KEY_NAME;SharedAccessKey=SHARED_ACCESS_KEY or Endpoint=sb://namespace_DNS_Name;EntityPath=EVENT_HUB_NAME;SharedAccessSignatureToken=SHARED_ACCESS_SIGNATURE_TOKEN |
字段
DefaultOperationTimeout |
Default operation timeout if timeout is not specified in the connection string. 30 seconds. |
方法
getEndpoint() |
Get the endpoint which can be used to connect to the ServiceBus Namespace |
getEntityPath() |
Get the entity path value from the connection string |
getOperationTimeout() |
Gets the duration after which a pending operation like Send or RECEIVE will time out. If a timeout is not specified, it defaults to DefaultOperationTimeout This value will be used by all operations which uses this ConnectionStringBuilder, unless explicitly over-ridden. |
getRetryPolicy() |
Get the retry policy instance that was created as part of this builder's creation. |
getSasKey() |
Get the shared access policy key value from the connection string or null. |
getSasKeyName() |
Get the shared access policy owner name from the connection string or null. |
getSharedAccessSignatureToken() |
Returns the shared access signature token from the connection string or null. |
getTransportType() |
TransportType on which all the communication for the Service Bus created using this ConnectionString. Default value is AMQP.
|
setOperationTimeout(final Duration operationTimeout) |
Set the OperationTimeout value in the Connection String. This value will be used by all operations which uses this ConnectionStringBuilder, unless explicitly over-ridden. ConnectionString with operationTimeout is not inter-operable between java and clients in other platforms. |
setRetryPolicy(final RetryPolicy retryPolicy) |
Set the retry policy. RetryPolicy is not Serialized as part of toString() and is not interoperable with ServiceBus clients in other platforms. |
setTransportType(final TransportType transportType) |
Set the TransportType value in the Connection String. If no TransportType is set, this defaults to AMQP.
|
toLoggableString() | |
toString() |
Returns an inter-operable connection string that can be used to connect to ServiceBus Namespace |