320 строки
63 KiB
YAML
320 строки
63 KiB
YAML
### YamlMime:JavaType
|
|
uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder"
|
|
name: "ServiceBusClientBuilder"
|
|
nameWithType: "ServiceBusClientBuilder"
|
|
summary: "This class provides a fluent builder API to aid the instantiation of clients to send and receive messages to/from Service Bus entities."
|
|
inheritances:
|
|
- "<xref href=\"java.lang.Object?displayProperty=fullName\" data-throw-if-not-resolved=\"False\" />"
|
|
inheritedClassMethods:
|
|
- classRef: "java.lang.<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>"
|
|
methodsRef:
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--\">clone</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-\">equals</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--\">finalize</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--\">getClass</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--\">hashCode</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--\">notify</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--\">notifyAll</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--\">toString</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--\">wait</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-\">wait</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-\">wait</a>"
|
|
syntax: "public final class **ServiceBusClientBuilder**</br> implements <xref href=\"com.azure.core.client.traits.TokenCredentialTrait?alt=com.azure.core.client.traits.TokenCredentialTrait&text=TokenCredentialTrait\" data-throw-if-not-resolved=\"False\" /><<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />>, <xref href=\"com.azure.core.client.traits.AzureNamedKeyCredentialTrait?alt=com.azure.core.client.traits.AzureNamedKeyCredentialTrait&text=AzureNamedKeyCredentialTrait\" data-throw-if-not-resolved=\"False\" /><<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />>, <xref href=\"com.azure.core.client.traits.ConnectionStringTrait?alt=com.azure.core.client.traits.ConnectionStringTrait&text=ConnectionStringTrait\" data-throw-if-not-resolved=\"False\" /><<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />>, <xref href=\"com.azure.core.client.traits.AzureSasCredentialTrait?alt=com.azure.core.client.traits.AzureSasCredentialTrait&text=AzureSasCredentialTrait\" data-throw-if-not-resolved=\"False\" /><<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />>, <xref href=\"com.azure.core.amqp.client.traits.AmqpTrait?alt=com.azure.core.amqp.client.traits.AmqpTrait&text=AmqpTrait\" data-throw-if-not-resolved=\"False\" /><<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />>, <xref href=\"com.azure.core.client.traits.ConfigurationTrait?alt=com.azure.core.client.traits.ConfigurationTrait&text=ConfigurationTrait\" data-throw-if-not-resolved=\"False\" /><<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />>"
|
|
constructors:
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusClientBuilder()"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusClientBuilder()"
|
|
name: "ServiceBusClientBuilder()"
|
|
nameWithType: "ServiceBusClientBuilder.ServiceBusClientBuilder()"
|
|
summary: "Creates a new instance with the default transport <xref uid=\"com.azure.core.amqp.AmqpTransportType.AMQP\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AmqpTransportType#AMQP\"></xref>."
|
|
syntax: "public ServiceBusClientBuilder()"
|
|
desc: "Creates a new instance with the default transport <xref uid=\"com.azure.core.amqp.AmqpTransportType.AMQP\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AmqpTransportType#AMQP\"></xref>."
|
|
methods:
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.clientOptions(com.azure.core.util.ClientOptions)"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.clientOptions(ClientOptions clientOptions)"
|
|
name: "clientOptions(ClientOptions clientOptions)"
|
|
nameWithType: "ServiceBusClientBuilder.clientOptions(ClientOptions clientOptions)"
|
|
summary: "Sets the <xref uid=\"com.azure.core.util.ClientOptions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ClientOptions\"></xref> to be sent from the client built from this builder, enabling customization of certain properties, as well as support the addition of custom header information."
|
|
parameters:
|
|
- description: "to be set on the client."
|
|
name: "clientOptions"
|
|
type: "<xref href=\"com.azure.core.util.ClientOptions?alt=com.azure.core.util.ClientOptions&text=ClientOptions\" data-throw-if-not-resolved=\"False\" />"
|
|
syntax: "public ServiceBusClientBuilder clientOptions(ClientOptions clientOptions)"
|
|
desc: "Sets the <xref uid=\"com.azure.core.util.ClientOptions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ClientOptions\"></xref> to be sent from the client built from this builder, enabling customization of certain properties, as well as support the addition of custom header information. Refer to the <xref uid=\"com.azure.core.util.ClientOptions\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ClientOptions\"></xref> documentation for more information."
|
|
returns:
|
|
description: "The updated <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.configuration(com.azure.core.util.Configuration)"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.configuration(Configuration configuration)"
|
|
name: "configuration(Configuration configuration)"
|
|
nameWithType: "ServiceBusClientBuilder.configuration(Configuration configuration)"
|
|
summary: "Sets the configuration store that is used during construction of the service client."
|
|
parameters:
|
|
- description: "The configuration store used to configure Service Bus clients."
|
|
name: "configuration"
|
|
type: "<xref href=\"com.azure.core.util.Configuration?alt=com.azure.core.util.Configuration&text=Configuration\" data-throw-if-not-resolved=\"False\" />"
|
|
syntax: "public ServiceBusClientBuilder configuration(Configuration configuration)"
|
|
desc: "Sets the configuration store that is used during construction of the service client. If not specified, the default configuration store is used to configure Service Bus clients. Use <xref uid=\"com.azure.core.util.Configuration.NONE\" data-throw-if-not-resolved=\"false\" data-raw-source=\"Configuration#NONE\"></xref> to bypass using configuration settings during construction."
|
|
returns:
|
|
description: "The updated <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.connectionString(java.lang.String)"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.connectionString(String connectionString)"
|
|
name: "connectionString(String connectionString)"
|
|
nameWithType: "ServiceBusClientBuilder.connectionString(String connectionString)"
|
|
summary: "Sets the connection string for a Service Bus namespace or a specific Service Bus resource."
|
|
parameters:
|
|
- description: "Connection string for a Service Bus namespace or a specific Service Bus resource."
|
|
name: "connectionString"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
syntax: "public ServiceBusClientBuilder connectionString(String connectionString)"
|
|
desc: "Sets the connection string for a Service Bus namespace or a specific Service Bus resource."
|
|
returns:
|
|
description: "The updated <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(com.azure.core.credential.AzureNamedKeyCredential)"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(AzureNamedKeyCredential credential)"
|
|
name: "credential(AzureNamedKeyCredential credential)"
|
|
nameWithType: "ServiceBusClientBuilder.credential(AzureNamedKeyCredential credential)"
|
|
summary: "Sets the credential with the shared access policies for the Service Bus resource."
|
|
parameters:
|
|
- description: "<xref uid=\"com.azure.core.credential.AzureNamedKeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AzureNamedKeyCredential\"></xref> to be used for authentication."
|
|
name: "credential"
|
|
type: "<xref href=\"com.azure.core.credential.AzureNamedKeyCredential?alt=com.azure.core.credential.AzureNamedKeyCredential&text=AzureNamedKeyCredential\" data-throw-if-not-resolved=\"False\" />"
|
|
syntax: "public ServiceBusClientBuilder credential(AzureNamedKeyCredential credential)"
|
|
desc: "Sets the credential with the shared access policies for the Service Bus resource. You can find the shared access policies on the azure portal or Azure CLI. For instance, on the portal, \"Shared Access policies\" has 'policy' and its 'Primary Key' and 'Secondary Key'. The 'name' attribute of the <xref uid=\"com.azure.core.credential.AzureNamedKeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AzureNamedKeyCredential\"></xref> is the 'policy' on portal and the 'key' attribute can be either 'Primary Key' or 'Secondary Key'. This method and <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.connectionString(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#connectionString(String)\"></xref> take the same information in different forms. But it allows you to update the name and key."
|
|
returns:
|
|
description: "The updated <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(com.azure.core.credential.AzureSasCredential)"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(AzureSasCredential credential)"
|
|
name: "credential(AzureSasCredential credential)"
|
|
nameWithType: "ServiceBusClientBuilder.credential(AzureSasCredential credential)"
|
|
summary: "Sets the credential with Shared Access Signature for the Service Bus resource."
|
|
parameters:
|
|
- description: "<xref uid=\"com.azure.core.credential.AzureSasCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AzureSasCredential\"></xref> to be used for authentication."
|
|
name: "credential"
|
|
type: "<xref href=\"com.azure.core.credential.AzureSasCredential?alt=com.azure.core.credential.AzureSasCredential&text=AzureSasCredential\" data-throw-if-not-resolved=\"False\" />"
|
|
syntax: "public ServiceBusClientBuilder credential(AzureSasCredential credential)"
|
|
desc: "Sets the credential with Shared Access Signature for the Service Bus resource. Refer to [ Service Bus access control with Shared Access Signatures][Service Bus access control with Shared Access Signatures].\n\n\n[Service Bus access control with Shared Access Signatures]: https://docs.microsoft.com/azure/service-bus-messaging/service-bus-sas"
|
|
returns:
|
|
description: "The updated <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(com.azure.core.credential.TokenCredential)"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(TokenCredential credential)"
|
|
name: "credential(TokenCredential credential)"
|
|
nameWithType: "ServiceBusClientBuilder.credential(TokenCredential credential)"
|
|
summary: "Sets the <xref uid=\"com.azure.core.credential.TokenCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TokenCredential\"></xref> used to authorize requests sent to the service."
|
|
parameters:
|
|
- description: "The token credential to use for authentication. Access controls may be specified by the\n ServiceBus namespace or the requested Service Bus entity, depending on Azure configuration."
|
|
name: "credential"
|
|
type: "<xref href=\"com.azure.core.credential.TokenCredential?alt=com.azure.core.credential.TokenCredential&text=TokenCredential\" data-throw-if-not-resolved=\"False\" />"
|
|
syntax: "public ServiceBusClientBuilder credential(TokenCredential credential)"
|
|
desc: "Sets the <xref uid=\"com.azure.core.credential.TokenCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TokenCredential\"></xref> used to authorize requests sent to the service. Refer to the Azure SDK for Java [identity and authentication][] documentation for more details on proper usage of the <xref uid=\"com.azure.core.credential.TokenCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TokenCredential\"></xref> type.\n\n\n[identity and authentication]: https://aka.ms/azsdk/java/docs/identity"
|
|
returns:
|
|
description: "The updated <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(java.lang.String,com.azure.core.credential.AzureNamedKeyCredential)"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(String fullyQualifiedNamespace, AzureNamedKeyCredential credential)"
|
|
name: "credential(String fullyQualifiedNamespace, AzureNamedKeyCredential credential)"
|
|
nameWithType: "ServiceBusClientBuilder.credential(String fullyQualifiedNamespace, AzureNamedKeyCredential credential)"
|
|
summary: "Sets the credential with the shared access policies for the Service Bus resource."
|
|
parameters:
|
|
- description: "The fully-qualified namespace for the Service Bus."
|
|
name: "fullyQualifiedNamespace"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
- description: "<xref uid=\"com.azure.core.credential.AzureNamedKeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AzureNamedKeyCredential\"></xref> to be used for authentication."
|
|
name: "credential"
|
|
type: "<xref href=\"com.azure.core.credential.AzureNamedKeyCredential?alt=com.azure.core.credential.AzureNamedKeyCredential&text=AzureNamedKeyCredential\" data-throw-if-not-resolved=\"False\" />"
|
|
syntax: "public ServiceBusClientBuilder credential(String fullyQualifiedNamespace, AzureNamedKeyCredential credential)"
|
|
desc: "Sets the credential with the shared access policies for the Service Bus resource. You can find the shared access policies on the azure portal or Azure CLI. For instance, on the portal, \"Shared Access policies\" has 'policy' and its 'Primary Key' and 'Secondary Key'. The 'name' attribute of the <xref uid=\"com.azure.core.credential.AzureNamedKeyCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AzureNamedKeyCredential\"></xref> is the 'policy' on portal and the 'key' attribute can be either 'Primary Key' or 'Secondary Key'. This method and <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.connectionString(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#connectionString(String)\"></xref> take the same information in different forms. But it allows you to update the name and key."
|
|
returns:
|
|
description: "The updated <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(java.lang.String,com.azure.core.credential.AzureSasCredential)"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(String fullyQualifiedNamespace, AzureSasCredential credential)"
|
|
name: "credential(String fullyQualifiedNamespace, AzureSasCredential credential)"
|
|
nameWithType: "ServiceBusClientBuilder.credential(String fullyQualifiedNamespace, AzureSasCredential credential)"
|
|
summary: "Sets the credential with Shared Access Signature for the Service Bus resource."
|
|
parameters:
|
|
- description: "The fully-qualified namespace for the Service Bus."
|
|
name: "fullyQualifiedNamespace"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
- description: "<xref uid=\"com.azure.core.credential.AzureSasCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AzureSasCredential\"></xref> to be used for authentication."
|
|
name: "credential"
|
|
type: "<xref href=\"com.azure.core.credential.AzureSasCredential?alt=com.azure.core.credential.AzureSasCredential&text=AzureSasCredential\" data-throw-if-not-resolved=\"False\" />"
|
|
syntax: "public ServiceBusClientBuilder credential(String fullyQualifiedNamespace, AzureSasCredential credential)"
|
|
desc: "Sets the credential with Shared Access Signature for the Service Bus resource. Refer to [ Service Bus access control with Shared Access Signatures][Service Bus access control with Shared Access Signatures].\n\n\n[Service Bus access control with Shared Access Signatures]: https://docs.microsoft.com/azure/service-bus-messaging/service-bus-sas"
|
|
returns:
|
|
description: "The updated <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(java.lang.String,com.azure.core.credential.TokenCredential)"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(String fullyQualifiedNamespace, TokenCredential credential)"
|
|
name: "credential(String fullyQualifiedNamespace, TokenCredential credential)"
|
|
nameWithType: "ServiceBusClientBuilder.credential(String fullyQualifiedNamespace, TokenCredential credential)"
|
|
summary: "Sets the credential by using a <xref uid=\"com.azure.core.credential.TokenCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TokenCredential\"></xref> for the Service Bus resource."
|
|
parameters:
|
|
- description: "The fully-qualified namespace for the Service Bus."
|
|
name: "fullyQualifiedNamespace"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
- description: "The token credential to use for authentication. Access controls may be specified by the\n ServiceBus namespace or the requested Service Bus entity, depending on Azure configuration."
|
|
name: "credential"
|
|
type: "<xref href=\"com.azure.core.credential.TokenCredential?alt=com.azure.core.credential.TokenCredential&text=TokenCredential\" data-throw-if-not-resolved=\"False\" />"
|
|
syntax: "public ServiceBusClientBuilder credential(String fullyQualifiedNamespace, TokenCredential credential)"
|
|
desc: "Sets the credential by using a <xref uid=\"com.azure.core.credential.TokenCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TokenCredential\"></xref> for the Service Bus resource. [ azure-identity][azure-identity] has multiple <xref uid=\"com.azure.core.credential.TokenCredential\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TokenCredential\"></xref> implementations that can be used to authenticate the access to the Service Bus resource.\n\n\n[azure-identity]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity"
|
|
returns:
|
|
description: "The updated <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.customEndpointAddress(java.lang.String)"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.customEndpointAddress(String customEndpointAddress)"
|
|
name: "customEndpointAddress(String customEndpointAddress)"
|
|
nameWithType: "ServiceBusClientBuilder.customEndpointAddress(String customEndpointAddress)"
|
|
summary: "Sets a custom endpoint address when connecting to the Service Bus service."
|
|
parameters:
|
|
- description: "The custom endpoint address."
|
|
name: "customEndpointAddress"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
syntax: "public ServiceBusClientBuilder customEndpointAddress(String customEndpointAddress)"
|
|
desc: "Sets a custom endpoint address when connecting to the Service Bus service. This can be useful when your network does not allow connecting to the standard Azure Service Bus endpoint address, but does allow connecting through an intermediary. For example: https://my.custom.endpoint.com:55300.\n\nIf no port is specified, the default port for the <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.transportType(com.azure.core.amqp.AmqpTransportType)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"transport type\"></xref> is used."
|
|
returns:
|
|
description: "The updated <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.enableCrossEntityTransactions()"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.enableCrossEntityTransactions()"
|
|
name: "enableCrossEntityTransactions()"
|
|
nameWithType: "ServiceBusClientBuilder.enableCrossEntityTransactions()"
|
|
summary: "Enable cross entity transaction on the connection to Service bus."
|
|
syntax: "public ServiceBusClientBuilder enableCrossEntityTransactions()"
|
|
desc: "Enable cross entity transaction on the connection to Service bus. Use this feature only when your transaction scope spans across different Service Bus entities. This feature is achieved by routing all the messages through one 'send-via' entity on server side as explained next. Once clients are created for multiple entities, the first entity that an operation occurs on becomes the entity through which all subsequent sends will be routed through ('send-via' entity). This enables the service to perform a transaction that is meant to span multiple entities. This means that subsequent entities that perform their first operation need to either be senders, or if they are receivers they need to be on the same entity as the initial entity through which all sends are routed through (otherwise the service would not be able to ensure that the transaction is committed because it cannot route a receive operation through a different entity). For instance, if you have SenderA (For entity A) and ReceiverB (For entity B) that are created from a client with cross-entity transactions enabled, you would need to receive first with ReceiverB to allow this to work. If you first send to entity A, and then attempted to receive from entity B, an exception would be thrown.\n\n**Avoid using non-transaction API on this client**\n\nSince this feature will set up connection to Service Bus optimised to enable this feature. Once all the clients have been setup, the first receiver or sender used will initialize 'send-via' queue as a single message transfer entity. All the messages will flow via this queue. Thus this client is not suitable for any non-transaction API.\n\n**When not to enable this feature**\n\nIf your transaction is involved in one Service bus entity only. For example you are receiving from one queue/subscription and you want to settle your own messages which are part of one transaction."
|
|
returns:
|
|
description: "The updated <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSenderClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.fullyQualifiedNamespace(java.lang.String)"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.fullyQualifiedNamespace(String fullyQualifiedNamespace)"
|
|
name: "fullyQualifiedNamespace(String fullyQualifiedNamespace)"
|
|
nameWithType: "ServiceBusClientBuilder.fullyQualifiedNamespace(String fullyQualifiedNamespace)"
|
|
summary: "Sets the fully-qualified namespace for the Service Bus."
|
|
parameters:
|
|
- description: "The fully-qualified namespace for the Service Bus."
|
|
name: "fullyQualifiedNamespace"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
syntax: "public ServiceBusClientBuilder fullyQualifiedNamespace(String fullyQualifiedNamespace)"
|
|
desc: "Sets the fully-qualified namespace for the Service Bus."
|
|
returns:
|
|
description: "The updated <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.processor()"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.processor()"
|
|
name: "processor()"
|
|
nameWithType: "ServiceBusClientBuilder.processor()"
|
|
summary: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusProcessorClientBuilder\"></xref> used to configure <xref uid=\"com.azure.messaging.servicebus.ServiceBusProcessorClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusProcessorClient\"></xref> instance."
|
|
syntax: "public ServiceBusClientBuilder.ServiceBusProcessorClientBuilder processor()"
|
|
desc: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusProcessorClientBuilder\"></xref> used to configure <xref uid=\"com.azure.messaging.servicebus.ServiceBusProcessorClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusProcessorClient\"></xref> instance."
|
|
returns:
|
|
description: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusProcessorClientBuilder\"></xref>."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusProcessorClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusProcessorClientBuilder&text=ServiceBusProcessorClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.proxyOptions(com.azure.core.amqp.ProxyOptions)"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.proxyOptions(ProxyOptions proxyOptions)"
|
|
name: "proxyOptions(ProxyOptions proxyOptions)"
|
|
nameWithType: "ServiceBusClientBuilder.proxyOptions(ProxyOptions proxyOptions)"
|
|
summary: "Sets the proxy configuration to use for <xref uid=\"com.azure.messaging.servicebus.ServiceBusSenderAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSenderAsyncClient\"></xref>."
|
|
parameters:
|
|
- description: "The proxy configuration to use."
|
|
name: "proxyOptions"
|
|
type: "<xref href=\"com.azure.core.amqp.ProxyOptions?alt=com.azure.core.amqp.ProxyOptions&text=ProxyOptions\" data-throw-if-not-resolved=\"False\" />"
|
|
syntax: "public ServiceBusClientBuilder proxyOptions(ProxyOptions proxyOptions)"
|
|
desc: "Sets the proxy configuration to use for <xref uid=\"com.azure.messaging.servicebus.ServiceBusSenderAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSenderAsyncClient\"></xref>. When a proxy is configured, <xref uid=\"com.azure.core.amqp.AmqpTransportType.AMQP_WEB_SOCKETS\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AmqpTransportType#AMQP_WEB_SOCKETS\"></xref> must be used for the transport type."
|
|
returns:
|
|
description: "The updated <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.receiver()"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.receiver()"
|
|
name: "receiver()"
|
|
nameWithType: "ServiceBusClientBuilder.receiver()"
|
|
summary: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusReceiverClientBuilder\"></xref> used to configure Service Bus message receivers."
|
|
syntax: "public ServiceBusClientBuilder.ServiceBusReceiverClientBuilder receiver()"
|
|
desc: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusReceiverClientBuilder\"></xref> used to configure Service Bus message receivers."
|
|
returns:
|
|
description: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusReceiverClientBuilder\"></xref>."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusReceiverClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusReceiverClientBuilder&text=ServiceBusReceiverClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.retryOptions(com.azure.core.amqp.AmqpRetryOptions)"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.retryOptions(AmqpRetryOptions retryOptions)"
|
|
name: "retryOptions(AmqpRetryOptions retryOptions)"
|
|
nameWithType: "ServiceBusClientBuilder.retryOptions(AmqpRetryOptions retryOptions)"
|
|
summary: "Sets the retry options for Service Bus clients."
|
|
parameters:
|
|
- description: "The retry options to use."
|
|
name: "retryOptions"
|
|
type: "<xref href=\"com.azure.core.amqp.AmqpRetryOptions?alt=com.azure.core.amqp.AmqpRetryOptions&text=AmqpRetryOptions\" data-throw-if-not-resolved=\"False\" />"
|
|
syntax: "public ServiceBusClientBuilder retryOptions(AmqpRetryOptions retryOptions)"
|
|
desc: "Sets the retry options for Service Bus clients. If not specified, the default retry options are used."
|
|
returns:
|
|
description: "The updated <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.ruleManager()"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.ruleManager()"
|
|
name: "ruleManager()"
|
|
nameWithType: "ServiceBusClientBuilder.ruleManager()"
|
|
summary: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusRuleManagerBuilder\"></xref> used to configure a Service Bus rule manager instance."
|
|
syntax: "public ServiceBusClientBuilder.ServiceBusRuleManagerBuilder ruleManager()"
|
|
desc: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusRuleManagerBuilder\"></xref> used to configure a Service Bus rule manager instance."
|
|
returns:
|
|
description: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusRuleManagerBuilder\"></xref>."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusRuleManagerBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusRuleManagerBuilder&text=ServiceBusRuleManagerBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.sender()"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.sender()"
|
|
name: "sender()"
|
|
nameWithType: "ServiceBusClientBuilder.sender()"
|
|
summary: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSenderClientBuilder\"></xref> used to configure Service Bus message senders."
|
|
syntax: "public ServiceBusClientBuilder.ServiceBusSenderClientBuilder sender()"
|
|
desc: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSenderClientBuilder\"></xref> used to configure Service Bus message senders."
|
|
returns:
|
|
description: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSenderClientBuilder\"></xref>."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusSenderClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusSenderClientBuilder&text=ServiceBusSenderClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.sessionProcessor()"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.sessionProcessor()"
|
|
name: "sessionProcessor()"
|
|
nameWithType: "ServiceBusClientBuilder.sessionProcessor()"
|
|
summary: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSessionProcessorClientBuilder\"></xref> used to configure a Service Bus processor instance that processes sessions."
|
|
syntax: "public ServiceBusClientBuilder.ServiceBusSessionProcessorClientBuilder sessionProcessor()"
|
|
desc: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSessionProcessorClientBuilder\"></xref> used to configure a Service Bus processor instance that processes sessions."
|
|
returns:
|
|
description: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSessionProcessorClientBuilder\"></xref>."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusSessionProcessorClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusSessionProcessorClientBuilder&text=ServiceBusSessionProcessorClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.sessionReceiver()"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.sessionReceiver()"
|
|
name: "sessionReceiver()"
|
|
nameWithType: "ServiceBusClientBuilder.sessionReceiver()"
|
|
summary: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSessionReceiverClientBuilder\"></xref> used to configure **session aware** Service Bus message receivers."
|
|
syntax: "public ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder sessionReceiver()"
|
|
desc: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSessionReceiverClientBuilder\"></xref> used to configure **session aware** Service Bus message receivers."
|
|
returns:
|
|
description: "A new instance of <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSessionReceiverClientBuilder\"></xref>."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusSessionReceiverClientBuilder&text=ServiceBusSessionReceiverClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.messaging.servicebus.ServiceBusClientBuilder.transportType(com.azure.core.amqp.AmqpTransportType)"
|
|
fullName: "com.azure.messaging.servicebus.ServiceBusClientBuilder.transportType(AmqpTransportType transportType)"
|
|
name: "transportType(AmqpTransportType transportType)"
|
|
nameWithType: "ServiceBusClientBuilder.transportType(AmqpTransportType transportType)"
|
|
summary: "Sets the transport type by which all the communication with Azure Service Bus occurs."
|
|
parameters:
|
|
- description: "The transport type to use."
|
|
name: "transportType"
|
|
type: "<xref href=\"com.azure.core.amqp.AmqpTransportType?alt=com.azure.core.amqp.AmqpTransportType&text=AmqpTransportType\" data-throw-if-not-resolved=\"False\" />"
|
|
syntax: "public ServiceBusClientBuilder transportType(AmqpTransportType transportType)"
|
|
desc: "Sets the transport type by which all the communication with Azure Service Bus occurs. Default value is <xref uid=\"com.azure.core.amqp.AmqpTransportType.AMQP\" data-throw-if-not-resolved=\"false\" data-raw-source=\"AmqpTransportType#AMQP\"></xref>."
|
|
returns:
|
|
description: "The updated <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> object."
|
|
type: "<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />"
|
|
type: "class"
|
|
desc: "This class provides a fluent builder API to aid the instantiation of clients to send and receive messages to/from Service Bus entities.\n\n**Credentials are required** to perform operations against Azure Service Bus. They can be set by using one of the following methods:\n\n * <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.connectionString(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#connectionString(String)\"></xref> with a connection string to the Service Bus *namespace*.\n * <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(java.lang.String,com.azure.core.credential.TokenCredential)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#credential(String, TokenCredential)\"></xref>, <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(java.lang.String,com.azure.core.credential.AzureSasCredential)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#credential(String, AzureSasCredential)\"></xref>, and <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(java.lang.String,com.azure.core.credential.AzureNamedKeyCredential)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#credential(String, AzureNamedKeyCredential)\"></xref> overloads can be used with the respective credentials that has access to the fully-qualified Service Bus namespace.\n * <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(com.azure.core.credential.TokenCredential)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#credential(TokenCredential)\"></xref>, <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(com.azure.core.credential.AzureSasCredential)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#credential(AzureSasCredential)\"></xref>, and <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.credential(com.azure.core.credential.AzureNamedKeyCredential)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#credential(AzureNamedKeyCredential)\"></xref> overloads can be used with its respective credentials. <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.fullyQualifiedNamespace(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#fullyQualifiedNamespace(String)\"></xref> **must be** set.\n\nThe credential used in the following samples is `DefaultAzureCredential` for authentication. It is appropriate for most scenarios, including local development and production environments. Additionally, we recommend using [managed identity][] for authentication in production environments. You can find more information on different ways of authenticating and their corresponding credential types in the [Azure Identity documentation\"][Azure Identity documentation].\n\n## Clients and sub-builders ##\n\n<xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusClientBuilder\"></xref> can instantiate several clients. The client to instantiate depends on whether users are publishing or receiving messages and if the entity has [Service Bus sessions][] enabled.\n\n * **Sending messages**: Use the <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.sender()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"sender()\"></xref> sub-builder to create <xref uid=\"com.azure.messaging.servicebus.ServiceBusSenderAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSenderAsyncClient\"></xref> and <xref uid=\"com.azure.messaging.servicebus.ServiceBusSenderClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSenderClient\"></xref>.\n * **Receiving messages**: Use the <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.receiver()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"receiver()\"></xref> sub-builder to create <xref uid=\"com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusReceiverAsyncClient\"></xref> and <xref uid=\"com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusReceiverAsyncClient\"></xref>.\n * **Receiving messages from a session-enabled Service Bus entity**: Use the <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.sessionReceiver()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"sessionReceiver()\"></xref> sub-builder to create <xref uid=\"com.azure.messaging.servicebus.ServiceBusSessionReceiverAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSessionReceiverAsyncClient\"></xref> and <xref uid=\"com.azure.messaging.servicebus.ServiceBusSessionReceiverClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSessionReceiverClient\"></xref>.\n * **Receiving messages using a callback-based processor**: Use the <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.processor()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"processor()\"></xref> sub-builder to create <xref uid=\"com.azure.messaging.servicebus.ServiceBusProcessorClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusProcessorClient\"></xref>.\n * **Receiving messages from a session-enabled Service Bus entity using a callback-based processor** : Use the <xref uid=\"com.azure.messaging.servicebus.ServiceBusClientBuilder.sessionProcessor()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"sessionProcessor()\"></xref> sub-builder to create <xref uid=\"com.azure.messaging.servicebus.ServiceBusProcessorClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusProcessorClient\"></xref>.\n\n## Sending messages ##\n\n**Sample: Instantiate a synchronous sender and send a message**\n\nThe following code sample demonstrates the creation of the synchronous client <xref uid=\"com.azure.messaging.servicebus.ServiceBusSenderClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSenderClient\"></xref> and sending a message. The `fullyQualifiedNamespace` is the Service Bus namespace's host name. It is listed under the \"Essentials\" panel after navigating to the Service Bus namespace via Azure Portal. The credential used is `DefaultAzureCredential` because it combines commonly used credentials in deployment and development and chooses the credential to used based on its running environment. When performance is important, consider using <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessageBatch\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.messaging.servicebus.ServiceBusMessageBatch\"></xref> to publish multiple messages at once.\n\n```java\nTokenCredential credential = new DefaultAzureCredentialBuilder().build();\n\n // 'fullyQualifiedNamespace' will look similar to \"{your-namespace}.servicebus.windows.net\"\n ServiceBusSenderClient sender = new ServiceBusClientBuilder()\n .credential(fullyQualifiedNamespace, credential)\n .sender()\n .queueName(queueName)\n .buildClient();\n\n sender.sendMessage(new ServiceBusMessage(\"Foo bar\"));\n```\n\n## Consuming messages ##\n\nThere are multiple clients for consuming messages from a Service Bus entity (that is not have [Service Bus sessions][] enabled).\n\n**Sample: Instantiate an asynchronous receiver**\n\nThe code example below demonstrates creating an async receiver. The credential used is `DefaultAzureCredential` for authentication. It is appropriate for most scenarios, including local development and production environments. <xref uid=\"com.azure.messaging.servicebus.models.ServiceBusReceiveMode.PEEK_LOCK\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusReceiveMode#PEEK_LOCK\"></xref> and <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"disableAutoComplete()\"></xref> are **strongly** recommended so users have control over message settlement.\n\n```java\nTokenCredential credential = new DefaultAzureCredentialBuilder().build();\n\n // 'fullyQualifiedNamespace' will look similar to \"{your-namespace}.servicebus.windows.net\"\n // 'disableAutoComplete' indicates that users will explicitly settle their message.\n ServiceBusReceiverAsyncClient asyncReceiver = new ServiceBusClientBuilder()\n .credential(fullyQualifiedNamespace, credential)\n .receiver()\n .disableAutoComplete()\n .queueName(queueName)\n .buildAsyncClient();\n\n // When users are done with the receiver, dispose of the receiver.\n // Clients should be long-lived objects as they require resources\n // and time to establish a connection to the service.\n asyncReceiver.close();\n```\n\n**Sample: Instantiate <xref uid=\"com.azure.messaging.servicebus.ServiceBusProcessorClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusProcessorClient\"></xref>**\n\nThe code example below demonstrates creating a processor client. The processor client is recommended for most production scenarios because it offers connection recovery. The credential used is `DefaultAzureCredential` for authentication. It is appropriate for most scenarios, including local development and production environments. <xref uid=\"com.azure.messaging.servicebus.models.ServiceBusReceiveMode.PEEK_LOCK\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusReceiveMode#PEEK_LOCK\"></xref> and <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"disableAutoComplete()\"></xref> are **strongly** recommended so users have control over message settlement.\n\n```java\n// Function that gets called whenever a message is received.\n Consumer<ServiceBusReceivedMessageContext> processMessage = context -> {\n final ServiceBusReceivedMessage message = context.getMessage();\n // Randomly complete or abandon each message. Ideally, in real-world scenarios, if the business logic\n // handling message reaches desired state such that it doesn't require Service Bus to redeliver\n // the same message, then context.complete() should be called otherwise context.abandon().\n final boolean success = Math.random() < 0.5;\n if (success) {\n try {\n context.complete();\n } catch (RuntimeException error) {\n System.out.printf(\"Completion of the message %s failed.%n Error: %s%n\",\n message.getMessageId(), error);\n }\n } else {\n try {\n context.abandon();\n } catch (RuntimeException error) {\n System.out.printf(\"Abandoning of the message %s failed.%nError: %s%n\",\n message.getMessageId(), error);\n }\n }\n };\n\n // Sample code that gets called if there's an error\n Consumer<ServiceBusErrorContext> processError = errorContext -> {\n if (errorContext.getException() instanceof ServiceBusException) {\n ServiceBusException exception = (ServiceBusException) errorContext.getException();\n\n System.out.printf(\"Error source: %s, reason %s%n\", errorContext.getErrorSource(),\n exception.getReason());\n } else {\n System.out.printf(\"Error occurred: %s%n\", errorContext.getException());\n }\n };\n\n TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build();\n\n // Create the processor client via the builder and its sub-builder\n // 'fullyQualifiedNamespace' will look similar to \"{your-namespace}.servicebus.windows.net\"\n ServiceBusProcessorClient processorClient = new ServiceBusClientBuilder()\n .credential(fullyQualifiedNamespace, tokenCredential)\n .processor()\n .queueName(queueName)\n .receiveMode(ServiceBusReceiveMode.PEEK_LOCK)\n .disableAutoComplete() // Make sure to explicitly opt in to manual settlement (e.g. complete, abandon).\n .processMessage(processMessage)\n .processError(processError)\n .disableAutoComplete()\n .buildProcessorClient();\n\n // Starts the processor in the background. Control returns immediately.\n processorClient.start();\n\n // Stop processor and dispose when done processing messages.\n processorClient.stop();\n processorClient.close();\n```\n\n## Consuming messages from a session-enabled Service Bus entity ##\n\nService Bus supports joint and ordered handling of unbounded sequences of messages through [Service Bus sessions][]. Sessions can be used as a first in, first out (FIFO) processing of messages. Queues and topics/subscriptions support Service Bus sessions, however, it must be [enabled at the time of entity creation][].\n\n**Sample: Sending a message to a session-enabled queue**\n\nThe snippet below demonstrates sending a message to a [Service Bus sessions][] enabled queue. Setting <xref uid=\"com.azure.messaging.servicebus.ServiceBusMessage.setMessageId(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusMessage#setMessageId(String)\"></xref> property to \"greetings\" will send the message to a Service Bus session with an id of \"greetings\".\n\n```java\n// 'fullyQualifiedNamespace' will look similar to \"{your-namespace}.servicebus.windows.net\"\n ServiceBusSenderClient sender = new ServiceBusClientBuilder()\n .credential(fullyQualifiedNamespace, new DefaultAzureCredentialBuilder().build())\n .sender()\n .queueName(sessionEnabledQueueName)\n .buildClient();\n\n // Setting sessionId publishes that message to a specific session, in this case, \"greeting\".\n ServiceBusMessage message = new ServiceBusMessage(\"Hello world\")\n .setSessionId(\"greetings\");\n\n sender.sendMessage(message);\n\n // Dispose of the sender.\n sender.close();\n```\n\n**Sample: Receive messages from first available session**\n\nTo process messages from the first available session, switch to <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSessionReceiverClientBuilder\"></xref> and build the session receiver client. Use <xref uid=\"com.azure.messaging.servicebus.ServiceBusSessionReceiverAsyncClient.acceptNextSession()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"acceptNextSession()\"></xref> to find the first available session to process messages from.\n\n```java\nTokenCredential credential = new DefaultAzureCredentialBuilder().build();\n\n // 'fullyQualifiedNamespace' will look similar to \"{your-namespace}.servicebus.windows.net\"\n // 'disableAutoComplete' indicates that users will explicitly settle their message.\n ServiceBusSessionReceiverAsyncClient sessionReceiver = new ServiceBusClientBuilder()\n .credential(fullyQualifiedNamespace, credential)\n .sessionReceiver()\n .disableAutoComplete()\n .queueName(sessionEnabledQueueName)\n .buildAsyncClient();\n\n // Creates a client to receive messages from the first available session. It waits until\n // AmqpRetryOptions.getTryTimeout() elapses. If no session is available within that operation timeout, it\n // completes with a retriable error. Otherwise, a receiver is returned when a lock on the session is acquired.\n Mono<ServiceBusReceiverAsyncClient> receiverMono = sessionReceiver.acceptNextSession();\n\n Flux<Void> receiveMessagesFlux = Flux.usingWhen(receiverMono,\n receiver -> receiver.receiveMessages().flatMap(message -> {\n System.out.println(\"Received message: \" + message.getBody());\n\n // Explicitly settle the message via complete, abandon, defer, dead-letter, etc.\n if (isMessageProcessed) {\n return receiver.complete(message);\n } else {\n return receiver.abandon(message);\n }\n }),\n receiver -> Mono.fromRunnable(() -> {\n // Dispose of the receiver and sessionReceiver when done receiving messages.\n receiver.close();\n sessionReceiver.close();\n }));\n\n // This is a non-blocking call that moves onto the next line of code after setting up and starting the receive\n // operation. Customers can keep a reference to `subscription` and dispose of it when they want to stop\n // receiving messages.\n Disposable subscription = receiveMessagesFlux.subscribe(unused -> {\n }, error -> System.out.println(\"Error occurred: \" + error),\n () -> System.out.println(\"Receiving complete.\"));\n```\n\n**Sample: Process messages from all sessions**\n\nThe following code sample demonstrates the creation the <xref uid=\"com.azure.messaging.servicebus.ServiceBusProcessorClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusProcessorClient\"></xref> that processes all available sessions in the queue. <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusSessionProcessorClientBuilder#maxConcurrentSessions(int)\"></xref> indicates how many sessions the processor will process at the same time. The credential used is `DefaultAzureCredential` for authentication. It is appropriate for most scenarios, including local development and production environments. <xref uid=\"com.azure.messaging.servicebus.models.ServiceBusReceiveMode.PEEK_LOCK\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ServiceBusReceiveMode#PEEK_LOCK\"></xref> and <xref uid=\"\" data-throw-if-not-resolved=\"false\" data-raw-source=\"disableAutoComplete()\"></xref> are **strongly** recommended so users have control over message settlement.\n\n```java\n// Function that gets called whenever a message is received.\n Consumer<ServiceBusReceivedMessageContext> onMessage = context -> {\n ServiceBusReceivedMessage message = context.getMessage();\n System.out.printf(\"Processing message. Session: %s, Sequence #: %s. Contents: %s%n\",\n message.getSessionId(), message.getSequenceNumber(), message.getBody());\n };\n\n Consumer<ServiceBusErrorContext> onError = context -> {\n System.out.printf(\"Error when receiving messages from namespace: '%s'. Entity: '%s'%n\",\n context.getFullyQualifiedNamespace(), context.getEntityPath());\n\n if (context.getException() instanceof ServiceBusException) {\n ServiceBusException exception = (ServiceBusException) context.getException();\n\n System.out.printf(\"Error source: %s, reason %s%n\", context.getErrorSource(),\n exception.getReason());\n } else {\n System.out.printf(\"Error occurred: %s%n\", context.getException());\n }\n };\n\n TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build();\n\n // Create the processor client via the builder and its sub-builder\n // 'fullyQualifiedNamespace' will look similar to \"{your-namespace}.servicebus.windows.net\"\n ServiceBusProcessorClient sessionProcessor = new ServiceBusClientBuilder()\n .credential(fullyQualifiedNamespace, tokenCredential)\n .sessionProcessor()\n .queueName(sessionEnabledQueueName)\n .receiveMode(ServiceBusReceiveMode.PEEK_LOCK)\n .disableAutoComplete()\n .maxConcurrentSessions(2)\n .processMessage(onMessage)\n .processError(onError)\n .buildProcessorClient();\n\n // Starts the processor in the background. Control returns immediately.\n sessionProcessor.start();\n\n // Stop processor and dispose when done processing messages.\n sessionProcessor.stop();\n sessionProcessor.close();\n```\n\n## Connection sharing ##\n\nThe creation of a connection to Service Bus requires resources. If your architecture allows, an application should share connection between clients which can be achieved by sharing the top level builder as shown below.\n\n**Sharing a connection between clients**\n\n```java\nTokenCredential credential = new DefaultAzureCredentialBuilder().build();\n\n // 'fullyQualifiedNamespace' will look similar to \"{your-namespace}.servicebus.windows.net\"\n // Any clients created from this builder will share the underlying connection.\n ServiceBusClientBuilder sharedConnectionBuilder = new ServiceBusClientBuilder()\n .credential(fullyQualifiedNamespace, credential);\n\n // Create receiver and sender which will share the connection.\n ServiceBusReceiverClient receiver = sharedConnectionBuilder\n .receiver()\n .receiveMode(ServiceBusReceiveMode.PEEK_LOCK)\n .queueName(queueName)\n .buildClient();\n ServiceBusSenderClient sender = sharedConnectionBuilder\n .sender()\n .queueName(queueName)\n .buildClient();\n\n // Use the clients and finally close them.\n try {\n sender.sendMessage(new ServiceBusMessage(\"payload\"));\n receiver.receiveMessages(1);\n } finally {\n // Clients should be long-lived objects as they require resources\n // and time to establish a connection to the service.\n sender.close();\n receiver.close();\n }\n```\n\n\n[managed identity]: https://learn.microsoft.com/azure/active-directory/managed-identities-azure-resources/\n[Azure Identity documentation]: https://learn.microsoft.com/java/api/overview/azure/identity-readme\n[Service Bus sessions]: https://learn.microsoft.com/azure/service-bus-messaging/message-sessions\n[enabled at the time of entity creation]: https://learn.microsoft.com/azure/service-bus-messaging/enable-message-sessions"
|
|
implements:
|
|
- "<xref href=\"com.azure.core.amqp.client.traits.AmqpTrait?alt=com.azure.core.amqp.client.traits.AmqpTrait&text=AmqpTrait\" data-throw-if-not-resolved=\"False\" /><<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />>"
|
|
- "<xref href=\"com.azure.core.client.traits.AzureNamedKeyCredentialTrait?alt=com.azure.core.client.traits.AzureNamedKeyCredentialTrait&text=AzureNamedKeyCredentialTrait\" data-throw-if-not-resolved=\"False\" /><<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />>"
|
|
- "<xref href=\"com.azure.core.client.traits.AzureSasCredentialTrait?alt=com.azure.core.client.traits.AzureSasCredentialTrait&text=AzureSasCredentialTrait\" data-throw-if-not-resolved=\"False\" /><<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />>"
|
|
- "<xref href=\"com.azure.core.client.traits.ConfigurationTrait?alt=com.azure.core.client.traits.ConfigurationTrait&text=ConfigurationTrait\" data-throw-if-not-resolved=\"False\" /><<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />>"
|
|
- "<xref href=\"com.azure.core.client.traits.ConnectionStringTrait?alt=com.azure.core.client.traits.ConnectionStringTrait&text=ConnectionStringTrait\" data-throw-if-not-resolved=\"False\" /><<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />>"
|
|
- "<xref href=\"com.azure.core.client.traits.TokenCredentialTrait?alt=com.azure.core.client.traits.TokenCredentialTrait&text=TokenCredentialTrait\" data-throw-if-not-resolved=\"False\" /><<xref href=\"com.azure.messaging.servicebus.ServiceBusClientBuilder?alt=com.azure.messaging.servicebus.ServiceBusClientBuilder&text=ServiceBusClientBuilder\" data-throw-if-not-resolved=\"False\" />>"
|
|
metadata: {}
|
|
package: "com.azure.messaging.servicebus"
|
|
artifact: com.azure:azure-messaging-servicebus:7.17.5
|