Follow-up to #49076.
Problem
In spring-cloud-azure-starter-eventhubs, AzureEventHubsClientBuilderConfiguration#eventHubClientBuilder is @ConditionalOnMissingBean(EventHubClientBuilder.class) (type-based). Whenever either AzureEventHubsConsumerClientConfiguration.DedicatedConsumerConnectionConfiguration or AzureEventHubsProducerClientConfiguration.DedicatedProducerConnectionConfiguration activates, it registers a named-but-EventHubClientBuilder-typed bean (springCloudAzureEventHubsConsumerClientBuilder / springCloudAzureEventHubsProducerClientBuilder). That suppresses the root builder.
If the other section has no sub-level override, its SharedConsumer/SharedProducerConnectionConfiguration still activates (its @ConditionalOnBean(EventHubClientBuilder.class) is now satisfied by the dedicated builder from the opposite section) and Spring resolves the unqualified EventHubClientBuilder parameter to that one bean. Result: the shared client targets the other section's event hub.
Repro (after #49076)
spring:
cloud:
azure:
eventhubs:
namespace: evhns-sample
event-hub-name: base-hub
consumer:
consumer-group: $Default
event-hub-name: override-hub
The same flaw triggers today (without #49076) when a user sets consumer.connection-string or consumer.namespace without a producer override (or vice versa); #49076 only extends the trigger to event-hub-name.
Scope
Out of scope for #49076 because the wiring flaw predates that PR. Plausible fixes:
- Name the root builder and switch
@ConditionalOnMissingBean(EventHubClientBuilder.class) to a name-based check so dedicated builders no longer suppress it.
- Or mark the root
@Primary (after the above) and add @Qualifier to the shared EventHubClientBuilder injection points.
- Add regression coverage in
AzureEventHubsConsumer/ProducerClientConfigurationTests for the asymmetric (one-side dedicated, one-side shared) configuration.
Unaffected: the Spring Messaging template path (AzureEventHubsMessagingAutoConfiguration → NamespaceProperties → DefaultEventHubsNamespaceProducerFactory) does not depend on these client builder beans.
cc @rujche
Follow-up to #49076.
Problem
In
spring-cloud-azure-starter-eventhubs,AzureEventHubsClientBuilderConfiguration#eventHubClientBuilderis@ConditionalOnMissingBean(EventHubClientBuilder.class)(type-based). Whenever eitherAzureEventHubsConsumerClientConfiguration.DedicatedConsumerConnectionConfigurationorAzureEventHubsProducerClientConfiguration.DedicatedProducerConnectionConfigurationactivates, it registers a named-but-EventHubClientBuilder-typed bean (springCloudAzureEventHubsConsumerClientBuilder/springCloudAzureEventHubsProducerClientBuilder). That suppresses the root builder.If the other section has no sub-level override, its
SharedConsumer/SharedProducerConnectionConfigurationstill activates (its@ConditionalOnBean(EventHubClientBuilder.class)is now satisfied by the dedicated builder from the opposite section) and Spring resolves the unqualifiedEventHubClientBuilderparameter to that one bean. Result: the shared client targets the other section's event hub.Repro (after #49076)
override-hub(correct, fixed by Fix Spring sub-level event-hub-name override and EventContext checkpoint offsetString propagation #49076).override-hubinstead ofbase-hub.The same flaw triggers today (without #49076) when a user sets
consumer.connection-stringorconsumer.namespacewithout a producer override (or vice versa); #49076 only extends the trigger toevent-hub-name.Scope
Out of scope for #49076 because the wiring flaw predates that PR. Plausible fixes:
@ConditionalOnMissingBean(EventHubClientBuilder.class)to a name-based check so dedicated builders no longer suppress it.@Primary(after the above) and add@Qualifierto the sharedEventHubClientBuilderinjection points.AzureEventHubsConsumer/ProducerClientConfigurationTestsfor the asymmetric (one-side dedicated, one-side shared) configuration.Unaffected: the Spring Messaging template path (
AzureEventHubsMessagingAutoConfiguration→NamespaceProperties→DefaultEventHubsNamespaceProducerFactory) does not depend on these client builder beans.cc @rujche