33
44package com .azure .spring .cloud .autoconfigure .implementation .eventhubs ;
55
6+ import com .azure .core .credential .TokenCredential ;
67import com .azure .messaging .eventhubs .CheckpointStore ;
78import com .azure .messaging .eventhubs .EventData ;
89import com .azure .spring .cloud .autoconfigure .implementation .condition .ConditionalOnAnyProperty ;
910import com .azure .spring .cloud .autoconfigure .implementation .eventhubs .properties .AzureEventHubsProperties ;
11+ import com .azure .spring .cloud .core .implementation .credential .resolver .AzureTokenCredentialResolver ;
1012import com .azure .spring .cloud .core .provider .connectionstring .ServiceConnectionStringProvider ;
1113import com .azure .spring .cloud .core .service .AzureServiceType ;
1214import com .azure .spring .messaging .ConsumerIdentifier ;
@@ -84,9 +86,14 @@ static class ProcessorContainerConfiguration {
8486 @ ConditionalOnMissingBean
8587 EventHubsProcessorFactory defaultEventHubsNamespaceProcessorFactory (
8688 NamespaceProperties properties , CheckpointStore checkpointStore ,
87- ObjectProvider <PropertiesSupplier <ConsumerIdentifier , ProcessorProperties >> suppliers ) {
88- return new DefaultEventHubsNamespaceProcessorFactory (checkpointStore , properties ,
89- suppliers .getIfAvailable ());
89+ ObjectProvider <PropertiesSupplier <ConsumerIdentifier , ProcessorProperties >> suppliers ,
90+ ObjectProvider <AzureTokenCredentialResolver > tokenCredentialResolvers ,
91+ ObjectProvider <TokenCredential > defaultTokenCredentials ) {
92+ DefaultEventHubsNamespaceProcessorFactory factory = new DefaultEventHubsNamespaceProcessorFactory (
93+ checkpointStore , properties , suppliers .getIfAvailable ());
94+ factory .setDefaultCredential (defaultTokenCredentials .getIfAvailable ());
95+ factory .setTokenCredentialResolver (tokenCredentialResolvers .getIfAvailable ());
96+ return factory ;
9097 }
9198
9299 }
@@ -98,8 +105,14 @@ static class EventHubsTemplateConfiguration {
98105 @ ConditionalOnMissingBean
99106 EventHubsProducerFactory defaultEventHubsNamespaceProducerFactory (
100107 NamespaceProperties properties ,
101- ObjectProvider <PropertiesSupplier <String , ProducerProperties >> suppliers ) {
102- return new DefaultEventHubsNamespaceProducerFactory (properties , suppliers .getIfAvailable ());
108+ ObjectProvider <PropertiesSupplier <String , ProducerProperties >> suppliers ,
109+ ObjectProvider <AzureTokenCredentialResolver > tokenCredentialResolvers ,
110+ ObjectProvider <TokenCredential > defaultTokenCredentials ) {
111+ DefaultEventHubsNamespaceProducerFactory factory = new DefaultEventHubsNamespaceProducerFactory (
112+ properties , suppliers .getIfAvailable ());
113+ factory .setDefaultCredential (defaultTokenCredentials .getIfAvailable ());
114+ factory .setTokenCredentialResolver (tokenCredentialResolvers .getIfAvailable ());
115+ return factory ;
103116 }
104117
105118 @ Bean
0 commit comments