Class DefaultEventHubsNamespaceProducerFactory

java.lang.Object
com.azure.spring.messaging.eventhubs.core.DefaultEventHubsNamespaceProducerFactory
All Implemented Interfaces:
EventHubsProducerFactory, org.springframework.beans.factory.DisposableBean

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

The created EventHubProducerAsyncClients are cached according to the event hub names. =

EventHubProducerAsyncClient 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

    • DefaultEventHubsNamespaceProducerFactory

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

      public DefaultEventHubsNamespaceProducerFactory(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 event hub.
  • Method Details

    • createProducer

      public com.azure.messaging.eventhubs.EventHubProducerAsyncClient createProducer(String eventHub)
      Description copied from interface: EventHubsProducerFactory
      Create EventHubProducerAsyncClient to send events to the event hub.
      Specified by:
      createProducer in interface EventHubsProducerFactory
      Parameters:
      eventHub - the event hub
      Returns:
      the producer.
    • addListener

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

      public boolean removeListener(EventHubsProducerFactory.Listener listener)
      Description copied from interface: EventHubsProducerFactory
      Remove a listener
      Specified by:
      removeListener in interface EventHubsProducerFactory
      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.eventhubs.EventHubClientBuilder> 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 eventHub, com.azure.spring.cloud.core.customizer.AzureServiceClientBuilderCustomizer<com.azure.messaging.eventhubs.EventHubClientBuilder> customizer)
      Add a service client builder customizer to customize the clients created from this factory with event hub name of value eventHub.
      Parameters:
      eventHub - the event hub name of the client.
      customizer - the provided customizer.