Class DefaultEventHubsNamespaceProcessorFactory

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

public final class DefaultEventHubsNamespaceProcessorFactory extends Object implements EventHubsProcessorFactory, org.springframework.beans.factory.DisposableBean
The EventHubsProcessorFactory implementation to produce new EventProcessorClient instances for provided CheckpointStore checkpointStore and optional NamespaceProperties and processor PropertiesSupplier on each createProcessor(java.lang.String, java.lang.String, com.azure.spring.cloud.service.listener.MessageListener<?>, com.azure.spring.cloud.service.eventhubs.consumer.EventHubsErrorHandler) invocation.

The created EventProcessorClients are cached according to the event hub names and consumer groups.

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

  • Constructor Details

    • DefaultEventHubsNamespaceProcessorFactory

      public DefaultEventHubsNamespaceProcessorFactory(com.azure.messaging.eventhubs.CheckpointStore checkpointStore)
      Construct a factory with the provided CheckpointStore.
      Parameters:
      checkpointStore - the checkpoint store.
    • DefaultEventHubsNamespaceProcessorFactory

      public DefaultEventHubsNamespaceProcessorFactory(com.azure.messaging.eventhubs.CheckpointStore checkpointStore, NamespaceProperties namespaceProperties)
      Construct a factory with the provided CheckpointStore and namespace level properties.
      Parameters:
      checkpointStore - the checkpoint store.
      namespaceProperties - the namespace properties.
    • DefaultEventHubsNamespaceProcessorFactory

      public DefaultEventHubsNamespaceProcessorFactory(com.azure.messaging.eventhubs.CheckpointStore checkpointStore, PropertiesSupplier<ConsumerIdentifier,ProcessorProperties> supplier)
      Construct a factory with the provided CheckpointStore and processor PropertiesSupplier.
      Parameters:
      checkpointStore - the checkpoint store.
      supplier - the PropertiesSupplier to supply ProcessorProperties for each event hub.
    • DefaultEventHubsNamespaceProcessorFactory

      public DefaultEventHubsNamespaceProcessorFactory(com.azure.messaging.eventhubs.CheckpointStore checkpointStore, NamespaceProperties namespaceProperties, PropertiesSupplier<ConsumerIdentifier,ProcessorProperties> supplier)
      Construct a factory with the provided CheckpointStore, namespace level properties and processor PropertiesSupplier.
      Parameters:
      checkpointStore - the checkpoint store.
      namespaceProperties - the namespace properties.
      supplier - the PropertiesSupplier to supply ProcessorProperties for each event hub.
  • Method Details

    • createProcessor

      public com.azure.messaging.eventhubs.EventProcessorClient createProcessor(@NonNull String eventHub, @NonNull String consumerGroup, @NonNull com.azure.spring.cloud.service.listener.MessageListener<?> listener, @NonNull com.azure.spring.cloud.service.eventhubs.consumer.EventHubsErrorHandler errorHandler)
      Description copied from interface: EventHubsProcessorFactory
      Create an EventProcessorClient to consume events from the specified event hub in the context of the given consumer group.
      Specified by:
      createProcessor in interface EventHubsProcessorFactory
      Parameters:
      eventHub - the event hub to consume events from.
      consumerGroup - the consumer group.
      listener - the MessageListener to consume events with.
      errorHandler - the error handler to handle the errors.
      Returns:
      the processor client.
    • createProcessor

      public com.azure.messaging.eventhubs.EventProcessorClient createProcessor(String eventHub, String consumerGroup, EventHubsContainerProperties containerProperties)
      Description copied from interface: EventHubsProcessorFactory
      Create an EventProcessorClient to consume events from the specified event hub in the context of the given consumer group.
      Specified by:
      createProcessor in interface EventHubsProcessorFactory
      Parameters:
      eventHub - the event hub to consume events from.
      consumerGroup - the consumer group.
      containerProperties - the EventHubsContainerProperties to describe the processor.
      Returns:
      the processor client.
    • destroy

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

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

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