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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.azure.spring.messaging.eventhubs.core.EventHubsProducerFactory
EventHubsProducerFactory.Listener -
Constructor Summary
ConstructorsConstructorDescriptionDefaultEventHubsNamespaceProducerFactory(NamespaceProperties namespaceProperties) Construct a factory with the provided namespace level configuration.DefaultEventHubsNamespaceProducerFactory(NamespaceProperties namespaceProperties, PropertiesSupplier<String, ProducerProperties> supplier) Construct a factory with the provided namespace level configuration and producerPropertiesSupplier. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBuilderCustomizer(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.voidaddBuilderCustomizer(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 valueeventHub.voidaddListener(EventHubsProducerFactory.Listener listener) Add a listener for this factory.com.azure.messaging.eventhubs.EventHubProducerAsyncClientcreateProducer(String eventHub) CreateEventHubProducerAsyncClientto send events to the event hub.voiddestroy()booleanRemove a listenervoidsetDefaultCredential(com.azure.core.credential.TokenCredential defaultCredential) Set the default credential for all clients generated from this factory.voidsetTokenCredentialResolver(com.azure.spring.cloud.core.credential.AzureCredentialResolver<com.azure.core.credential.TokenCredential> tokenCredentialResolver) Set the token credential resolver.
-
Constructor Details
-
DefaultEventHubsNamespaceProducerFactory
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 producerPropertiesSupplier.- Parameters:
namespaceProperties- the namespace properties.supplier- thePropertiesSupplierto supplyProducerPropertiesfor each event hub.
-
-
Method Details
-
createProducer
Description copied from interface:EventHubsProducerFactoryCreateEventHubProducerAsyncClientto send events to the event hub.- Specified by:
createProducerin interfaceEventHubsProducerFactory- Parameters:
eventHub- the event hub- Returns:
- the producer.
-
addListener
Description copied from interface:EventHubsProducerFactoryAdd a listener for this factory.- Specified by:
addListenerin interfaceEventHubsProducerFactory- Parameters:
listener- the listener
-
removeListener
Description copied from interface:EventHubsProducerFactoryRemove a listener- Specified by:
removeListenerin interfaceEventHubsProducerFactory- Parameters:
listener- the listener- Returns:
- true if removed.
-
destroy
public void destroy()- Specified by:
destroyin interfaceorg.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 valueeventHub.- Parameters:
eventHub- the event hub name of the client.customizer- the provided customizer.
-