Class EventHubConnectionStringProperties
java.lang.Object
com.azure.messaging.eventhubs.models.EventHubConnectionStringProperties
A utility class that parses a connection string into sections. An Event Hubs connection string is a set of key-value
pairs separated by semi-colon. A typical example is
"Endpoint=sb://foo.EventHub.windows.net/;SharedAccessKeyName=someKeyName;SharedAccessKey=someKeyValue"
.
A connection may have the following sections:
- Endpoint, which is mandatory. The hostname part of it is the "Fully qualified namespace".
- SharedAccessKeyName and SharedAccessKey, optional, used to authenticate the access to the EventHub.
- SharedAccessSignature, optional, an alternative way to authenticate the access to the EventHub.
- EntityPath, optional, the queue name or the topic name under the service namespace
When you have an Event Hubs connection string, you can use EventHubClientBuilder.connectionString(String)
to build a client. If you'd like to use a TokenCredential
to access an Event Hub, you can use this utility
class to get the fully qualified namespace and entity path from the connection
string and then use EventHubClientBuilder.credential(String, String, TokenCredential)
.
-
Method Summary
Modifier and TypeMethodDescriptionGets the "Endpoint" value of the connection string.Gets the "EntityPath" value of the connection string.Gets the fully qualified namespace, or hostname, from the connection string "Endpoint" section.Gets the "SharedAccessSignature" section of the connection string.Gets the "SharedAccessKeyName" section of the connection string.Parse a Event Hub connection string into an instance of this class.
-
Method Details
-
parse
Parse a Event Hub connection string into an instance of this class.- Parameters:
connectionString
- The connection string to be parsed.- Returns:
- An instance of this class.
- Throws:
NullPointerException
- ifconnectionString
is null.IllegalArgumentException
- if theconnectionString
is empty or malformed.
-
getEntityPath
Gets the "EntityPath" value of the connection string.- Returns:
- The entity path, or
null
if the connection string doesn't have an "EntityPath".
-
getEndpoint
Gets the "Endpoint" value of the connection string.- Returns:
- The endpoint.
-
getFullyQualifiedNamespace
Gets the fully qualified namespace, or hostname, from the connection string "Endpoint" section.- Returns:
- The fully qualified namespace.
-