Support to inherit ServiceBusClientBuilder configurations#49777
Support to inherit ServiceBusClientBuilder configurations#49777moarychan wants to merge 13 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request addresses #49742 by ensuring Service Bus processor (and other sub-client) creation can preserve ServiceBusClientBuilder configuration applied via AzureServiceClientBuilderCustomizer (notably ClientOptions/TracingOptions) instead of having it overwritten during sub-client builder configuration.
Changes:
- Introduces a new
inherit-configurationproperty (nullable, treated astrueby default) and propagates it through Service Bus namespace/producer/consumer/processor property models and mergers. - Updates Service Bus sub-client builder factory behavior to optionally skip re-applying property-derived configuration to the underlying
ServiceBusClientBuilder, preventing customizer configuration from being overwritten. - Aligns listener container factory bean name constants/usages and adds unit tests for the new inheritance behavior.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/spring/spring-messaging-azure/src/main/java/com/azure/spring/messaging/implementation/config/AzureListenerEndpoint.java | Fixes minor grammar in interface JavaDoc. |
| sdk/spring/spring-messaging-azure-servicebus/src/test/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesParentMergerTests.java | Adds coverage for inheritConfiguration precedence (parent vs child). |
| sdk/spring/spring-messaging-azure-servicebus/src/test/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ConsumerPropertiesParentMergerTests.java | Adds coverage for inheritConfiguration precedence (parent vs child). |
| sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/SenderPropertiesParentMerger.java | Propagates inheritConfiguration from parent/child into merged producer properties. |
| sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesParentMerger.java | Propagates inheritConfiguration from namespace parent into processor properties. |
| sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesMerger.java | Includes inheritConfiguration in processor property copying logic. |
| sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ConsumerPropertiesParentMerger.java | Propagates inheritConfiguration into merged consumer properties and copy helper. |
| sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/core/annotation/ServiceBusListenerAnnotationBeanPostProcessor.java | Exposes default container factory bean name constant publicly for reuse. |
| sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/core/annotation/ServiceBusListener.java | Fixes documented default container factory bean name to match actual default. |
| sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/core/properties/CommonProperties.java | Adds inheritConfiguration property to common Service Bus properties. |
| sdk/spring/spring-messaging-azure-eventhubs/src/main/java/com/azure/spring/messaging/eventhubs/implementation/core/annotation/EventHubsListenerAnnotationBeanPostProcessor.java | Exposes default container factory bean name constant publicly for reuse. |
| sdk/spring/spring-messaging-azure-eventhubs/src/main/java/com/azure/spring/messaging/eventhubs/implementation/core/annotation/EventHubsListener.java | Fixes documented default container factory bean name to match actual default. |
| sdk/spring/spring-cloud-azure-service/src/test/java/com/azure/spring/cloud/service/implementation/servicebus/properties/ServiceBusClientCommonTestProperties.java | Adds inheritConfiguration to test properties used by factory tests. |
| sdk/spring/spring-cloud-azure-service/src/test/java/com/azure/spring/cloud/service/implementation/servicebus/factory/AbstractServiceBusSubClientBuilderFactoryTests.java | Adds tests ensuring inheritConfiguration=false prevents overwriting shared builder config. |
| sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/cloud/service/implementation/servicebus/properties/ServiceBusClientCommonProperties.java | Adds new getInheritConfiguration() contract and documents null-as-true behavior. |
| sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/cloud/service/implementation/servicebus/lifecycle/ServiceBusProcessorClientLifecycleManager.java | Fixes a minor grammar issue in class JavaDoc. |
| sdk/spring/spring-cloud-azure-service/src/main/java/com/azure/spring/cloud/service/implementation/servicebus/factory/AbstractServiceBusSubClientBuilderFactory.java | Implements inheritance gating to prevent property-derived overwrites of ServiceBusClientBuilder config. |
| sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/implementation/servicebus/properties/AzureServiceBusPropertiesTest.java | Adds tests for default null and inheritance/override behavior in autoconfig properties. |
| sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/servicebus/properties/AzureServiceBusProperties.java | Propagates inheritConfiguration into built producer/consumer/processor property objects. |
| sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/servicebus/properties/AzureServiceBusCommonProperties.java | Adds namespace-level inheritConfiguration property to autoconfig model. |
| sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/messaging/AzureMessagingListenerAutoConfiguration.java | Reuses exposed constants for container factory bean naming to avoid string duplication. |
| sdk/spring/CHANGELOG.md | Documents the new inherit-configuration property and its intended effect. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| propertyMapper.from(parent.getEntityName()).to(properties::setEntityName); | ||
| propertyMapper.from(parent.getEntityType()).to(properties::setEntityType); | ||
| propertyMapper.from(parent.getCustomEndpointAddress()).to(properties::setCustomEndpointAddress); | ||
| propertyMapper.from(parent.getInheritConfiguration()).to(properties::setInheritConfiguration); | ||
|
|
||
| propertyMapper.from(child.getDomainName()).to(properties::setDomainName); | ||
| propertyMapper.from(child.getNamespace()).to(properties::setNamespace); | ||
| propertyMapper.from(child.getConnectionString()).to(properties::setConnectionString); | ||
| propertyMapper.from(child.getEntityName()).to(properties::setEntityName); | ||
| propertyMapper.from(child.getEntityType()).to(properties::setEntityType); | ||
| propertyMapper.from(child.getCustomEndpointAddress()).to(properties::setCustomEndpointAddress); | ||
| propertyMapper.from(child.getInheritConfiguration()).to(properties::setInheritConfiguration); |
There was a problem hiding this comment.
Added inheritConfigurationShouldFollowParentChildPrecedence to ProducerPropertiesParentMergerTests in 0c0c04c, mirroring the consumer/processor merger tests.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: moarychan <19926623+moarychan@users.noreply.github.com>
| * This class implements {@code SmartLifecycle} to auto start {@link ServiceBusProcessorClient} when the Spring Application Context starts, | ||
| * And stop the {@link ServiceBusProcessorClient} when the Spring Application Context stops. | ||
| * NOTE, there is not need to call {@link #start()} or {@link #stop()} explicitly, as the {@link ServiceBusProcessorClient} will be started and stopped automatically. | ||
| * NOTE, there is no need to call {@link #start()} or {@link #stop()} explicitly, as the {@link ServiceBusProcessorClient} will be started and stopped automatically. | ||
| * And since the {@link ServiceBusProcessorClient} is a {@link AutoCloseable}, there is no need to call {@link ServiceBusProcessorClient#close()} explicitly. |
There was a problem hiding this comment.
Reflowed the JavaDoc block to keep each line within the 120-character Checkstyle limit in 9349e3c.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…hars Co-authored-by: moarychan <19926623+moarychan@users.noreply.github.com>
Alternative Solution: Restore Customizers in
|
Description
Fixes #49742
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines