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 EventProcessorClient
s 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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.azure.spring.messaging.eventhubs.core.EventHubsProcessorFactory
EventHubsProcessorFactory.Listener
-
Constructor Summary
ConstructorDescriptionDefaultEventHubsNamespaceProcessorFactory
(com.azure.messaging.eventhubs.CheckpointStore checkpointStore) Construct a factory with the providedCheckpointStore
.DefaultEventHubsNamespaceProcessorFactory
(com.azure.messaging.eventhubs.CheckpointStore checkpointStore, NamespaceProperties namespaceProperties) Construct a factory with the providedCheckpointStore
and namespace level properties.DefaultEventHubsNamespaceProcessorFactory
(com.azure.messaging.eventhubs.CheckpointStore checkpointStore, NamespaceProperties namespaceProperties, PropertiesSupplier<ConsumerIdentifier, ProcessorProperties> supplier) Construct a factory with the providedCheckpointStore
, namespace level properties and processorPropertiesSupplier
.DefaultEventHubsNamespaceProcessorFactory
(com.azure.messaging.eventhubs.CheckpointStore checkpointStore, PropertiesSupplier<ConsumerIdentifier, ProcessorProperties> supplier) Construct a factory with the providedCheckpointStore
and processorPropertiesSupplier
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.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 valueeventHub
and consumer group of valueconsumerGroup
.void
Add a listener for this factory.com.azure.messaging.eventhubs.EventProcessorClient
createProcessor
(String eventHub, String consumerGroup, com.azure.spring.cloud.service.listener.MessageListener<?> listener, com.azure.spring.cloud.service.eventhubs.consumer.EventHubsErrorHandler errorHandler) Create anEventProcessorClient
to consume events from the specified event hub in the context of the given consumer group.com.azure.messaging.eventhubs.EventProcessorClient
createProcessor
(String eventHub, String consumerGroup, EventHubsContainerProperties containerProperties) Create anEventProcessorClient
to consume events from the specified event hub in the context of the given consumer group.void
destroy()
boolean
Remove a listener from this factory.void
setDefaultCredential
(com.azure.core.credential.TokenCredential defaultCredential) Set the default credential for all clients generated from this factory.void
setTokenCredentialResolver
(com.azure.spring.cloud.core.credential.AzureCredentialResolver<com.azure.core.credential.TokenCredential> tokenCredentialResolver) Set the token credential resolver.
-
Constructor Details
-
DefaultEventHubsNamespaceProcessorFactory
public DefaultEventHubsNamespaceProcessorFactory(com.azure.messaging.eventhubs.CheckpointStore checkpointStore) Construct a factory with the providedCheckpointStore
.- Parameters:
checkpointStore
- the checkpoint store.
-
DefaultEventHubsNamespaceProcessorFactory
public DefaultEventHubsNamespaceProcessorFactory(com.azure.messaging.eventhubs.CheckpointStore checkpointStore, NamespaceProperties namespaceProperties) Construct a factory with the providedCheckpointStore
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 providedCheckpointStore
and processorPropertiesSupplier
.- Parameters:
checkpointStore
- the checkpoint store.supplier
- thePropertiesSupplier
to supplyProcessorProperties
for each event hub.
-
DefaultEventHubsNamespaceProcessorFactory
public DefaultEventHubsNamespaceProcessorFactory(com.azure.messaging.eventhubs.CheckpointStore checkpointStore, NamespaceProperties namespaceProperties, PropertiesSupplier<ConsumerIdentifier, ProcessorProperties> supplier) Construct a factory with the providedCheckpointStore
, namespace level properties and processorPropertiesSupplier
.- Parameters:
checkpointStore
- the checkpoint store.namespaceProperties
- the namespace properties.supplier
- thePropertiesSupplier
to supplyProcessorProperties
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 anEventProcessorClient
to consume events from the specified event hub in the context of the given consumer group.- Specified by:
createProcessor
in interfaceEventHubsProcessorFactory
- Parameters:
eventHub
- the event hub to consume events from.consumerGroup
- the consumer group.listener
- theMessageListener
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 anEventProcessorClient
to consume events from the specified event hub in the context of the given consumer group.- Specified by:
createProcessor
in interfaceEventHubsProcessorFactory
- Parameters:
eventHub
- the event hub to consume events from.consumerGroup
- the consumer group.containerProperties
- theEventHubsContainerProperties
to describe the processor.- Returns:
- the processor client.
-
destroy
public void destroy()- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
-
addListener
Description copied from interface:EventHubsProcessorFactory
Add a listener for this factory.- Specified by:
addListener
in interfaceEventHubsProcessorFactory
- Parameters:
listener
- the listener.
-
removeListener
Description copied from interface:EventHubsProcessorFactory
Remove a listener from this factory.- Specified by:
removeListener
in interfaceEventHubsProcessorFactory
- 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 valueeventHub
and consumer group of valueconsumerGroup
.- Parameters:
eventHub
- the event hub name of the client.consumerGroup
- the consumer group of the client.customizer
- the provided customizer.
-