Class DefaultServiceBusNamespaceProducerFactory

java.lang.Object
com.azure.spring.messaging.servicebus.core.DefaultServiceBusNamespaceProducerFactory
All Implemented Interfaces:
ServiceBusProducerFactory, org.springframework.beans.factory.DisposableBean

public final class DefaultServiceBusNamespaceProducerFactory extends Object implements ServiceBusProducerFactory, org.springframework.beans.factory.DisposableBean
The ServiceBusProducerFactory implementation to produce new ServiceBusSenderAsyncClient instances for provided NamespaceProperties and optional producer PropertiesSupplier on each createProducer(java.lang.String) invocation.

ServiceBusSenderAsyncClient produced by this factory will share the same namespace level configuration, but if a configuration entry is provided at both producer and namespace level, the producer level configuration will take advantage.

  • Constructor Details

    • DefaultServiceBusNamespaceProducerFactory

      public DefaultServiceBusNamespaceProducerFactory(NamespaceProperties namespaceProperties)
      Construct a factory with the provided namespace level configuration.
      Parameters:
      namespaceProperties - the namespace properties
    • DefaultServiceBusNamespaceProducerFactory

      public DefaultServiceBusNamespaceProducerFactory(NamespaceProperties namespaceProperties, PropertiesSupplier<String,ProducerProperties> supplier)
      Construct a factory with the provided namespace level configuration and producer PropertiesSupplier.
      Parameters:
      namespaceProperties - the namespace properties.
      supplier - the PropertiesSupplier to supply ProducerProperties for each queue/topic entity.
  • Method Details

    • createProducer

      public com.azure.messaging.servicebus.ServiceBusSenderAsyncClient createProducer(String name)
      Description copied from interface: ServiceBusProducerFactory
      Create ServiceBusSenderAsyncClient to send events to the Service Bus queue/topic entity.
      Specified by:
      createProducer in interface ServiceBusProducerFactory
      Parameters:
      name - the destination entity name
      Returns:
      the producer.
    • createProducer

      public com.azure.messaging.servicebus.ServiceBusSenderAsyncClient createProducer(String name, com.azure.spring.cloud.service.servicebus.properties.ServiceBusEntityType entityType)
      Description copied from interface: ServiceBusProducerFactory
      Create ServiceBusSenderAsyncClient to send events to the Service Bus queue/topic entity with explicit ServiceBusEntityType.
      Specified by:
      createProducer in interface ServiceBusProducerFactory
      Parameters:
      name - the destination entity name.
      entityType - the Service Bus entity type.
      Returns:
      the producer.
    • addListener

      public void addListener(ServiceBusProducerFactory.Listener listener)
      Description copied from interface: ServiceBusProducerFactory
      Add a listener for this factory.
      Specified by:
      addListener in interface ServiceBusProducerFactory
      Parameters:
      listener - the listener
    • removeListener

      public boolean removeListener(ServiceBusProducerFactory.Listener listener)
      Description copied from interface: ServiceBusProducerFactory
      Remove a listener
      Specified by:
      removeListener in interface ServiceBusProducerFactory
      Parameters:
      listener - the listener
      Returns:
      true if removed.
    • destroy

      public void destroy()
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean
    • setTokenCredentialResolver

      public void setTokenCredentialResolver(com.azure.spring.cloud.core.credential.AzureCredentialResolver<com.azure.core.credential.TokenCredential> tokenCredentialResolver)
      Set the token credential resolver.
      Parameters:
      tokenCredentialResolver - The token credential resolver.
    • setDefaultCredential

      public void setDefaultCredential(com.azure.core.credential.TokenCredential defaultCredential)
      Set the default credential for all clients generated from this factory.
      Parameters:
      defaultCredential - The default credential.
    • addBuilderCustomizer

      public void addBuilderCustomizer(com.azure.spring.cloud.core.customizer.AzureServiceClientBuilderCustomizer<com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusSenderClientBuilder> customizer)
      Add a service client builder customizer to customize all the clients created from this factory.
      Parameters:
      customizer - the provided customizer.
    • addBuilderCustomizer

      public void addBuilderCustomizer(String entityName, com.azure.spring.cloud.core.customizer.AzureServiceClientBuilderCustomizer<com.azure.messaging.servicebus.ServiceBusClientBuilder.ServiceBusSenderClientBuilder> customizer)
      Add a service client builder customizer to customize the clients created from this factory with service bus entity name of value entityName.
      Parameters:
      entityName - the entity name of the client.
      customizer - the provided customizer.