-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add ConnectionDetails support for EventHubs #47926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ners, and docker-compose Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
API Change CheckAPIView identified API level changes in this PR and created the following API reviews com.azure.spring:spring-cloud-azure-docker-compose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements Spring Boot ConnectionDetails abstraction for EventHubs, following the established pattern from ServiceBus, Cosmos DB, and Storage services. It enables seamless integration with Testcontainers and Docker Compose for EventHubs emulator auto-configuration.
Changes:
- Added ConnectionDetails infrastructure in the autoconfigure module with conditional configuration beans
- Implemented Testcontainers factory for EventHubsEmulatorContainer integration with test coverage
- Implemented Docker Compose factory for eventhubs-emulator service detection with test coverage
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/eventhubs/properties/AzureEventHubsConnectionDetails.java |
Interface defining connection string abstraction for EventHubs ConnectionDetails |
sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/eventhubs/properties/AzureEventHubsPropertiesConfiguration.java |
Configuration class orchestrating conditional property bean creation |
sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/eventhubs/properties/ConfigurationWithConnectionDetailsBean.java |
Conditional bean configuration when ConnectionDetails is available |
sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/eventhubs/properties/ConfigurationWithoutConnectionDetailsBean.java |
Fallback bean configuration when ConnectionDetails is not available (missing conditional on enabled flag) |
sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/eventhubs/AzureEventHubsAutoConfiguration.java |
Refactored to delegate property configuration to new properties configuration classes |
sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/implementation/eventhubs/CustomAzureEventHubsConnectionDetails.java |
Test implementation of ConnectionDetails for validation |
sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/implementation/eventhubs/AzureEventHubsAutoConfigurationTests.java |
Added test to verify ConnectionDetails takes precedence over properties |
sdk/spring/spring-cloud-azure-testcontainers/src/main/java/com/azure/spring/cloud/testcontainers/implementation/service/connection/eventhubs/EventHubsContainerConnectionDetailsFactory.java |
Factory for creating ConnectionDetails from EventHubsEmulatorContainer |
sdk/spring/spring-cloud-azure-testcontainers/src/main/resources/META-INF/spring.factories |
Registered EventHubs container factory for service connection discovery |
sdk/spring/spring-cloud-azure-testcontainers/src/test/java/com/azure/spring/cloud/testcontainers/implementation/service/connection/eventhubs/EventHubsContainerConnectionDetailsFactoryTests.java |
Integration test validating Testcontainers auto-configuration |
sdk/spring/spring-cloud-azure-testcontainers/src/test/resources/eventhubs/Config.json |
EventHubs emulator configuration for tests |
sdk/spring/spring-cloud-azure-testcontainers/pom.xml |
Added optional dependency on azure-messaging-eventhubs |
sdk/spring/spring-cloud-azure-docker-compose/src/main/java/com/azure/spring/cloud/docker/compose/implementation/service/connection/eventhubs/EventHubsDockerComposeConnectionDetailsFactory.java |
Factory for creating ConnectionDetails from Docker Compose service |
sdk/spring/spring-cloud-azure-docker-compose/src/main/resources/META-INF/spring.factories |
Registered EventHubs Docker Compose factory for service connection discovery |
sdk/spring/spring-cloud-azure-docker-compose/src/test/java/com/azure/spring/cloud/docker/compose/implementation/service/connection/eventhubs/EventHubsDockerComposeConnectionDetailsFactoryTests.java |
Integration test validating Docker Compose auto-configuration |
sdk/spring/spring-cloud-azure-docker-compose/src/test/resources/com/azure/spring/cloud/docker/compose/implementation/service/connection/eventhubs/eventhubs-compose.yaml |
Docker Compose configuration for tests |
sdk/spring/spring-cloud-azure-docker-compose/src/test/resources/com/azure/spring/cloud/docker/compose/implementation/service/connection/eventhubs/Config.json |
EventHubs emulator configuration for Docker Compose tests |
sdk/spring/spring-cloud-azure-docker-compose/pom.xml |
Added optional dependency on azure-messaging-eventhubs |
...configure/implementation/eventhubs/properties/ConfigurationWithoutConnectionDetailsBean.java
Show resolved
Hide resolved
EventHubsDockerComposeConnectionDetailsFactoryTests passed in wsl nowHere is the log: rujche@RujcheThinkPad:~/work/git-repositories/main/azure-sdk-for-java$ git pull
remote: Enumerating objects: 48, done.
remote: Counting objects: 100% (32/32), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 48 (delta 5), reused 19 (delta 5), pack-reused 16 (from 2)
Unpacking objects: 100% (48/48), 34.58 KiB | 823.00 KiB/s, done.
From https://github.com/Azure/azure-sdk-for-java
7fc8e138dfa..40bf4bb23e1 copilot/add-support-connectiondetails -> origin/copilot/add-support-connectiondetails
5fbf70da6c5..cee16633f4d main -> origin/main
Updating 7fc8e138dfa..40bf4bb23e1
Fast-forward
.../src/test/resources/com/azure/spring/cloud/docker/compose/implementation/service/connection/eventhubs/eventhubs-compose.yaml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
rujche@RujcheThinkPad:~/work/git-repositories/main/azure-sdk-for-java$ mvn -Dmaven.repo.local=/mnt/c/Users/rujche/.m2/repository -pl sdk/spring/spring-cloud-azure-docker-compose -Dtest=EventHubsDockerComposeConnectionDetailsFactoryTests,ServiceBusDockerComposeConnectionDetailsFactoryTests -DfailIfNoTests=false test
[INFO] Scanning for projects...
[INFO]
[INFO] ---------< com.azure.spring:spring-cloud-azure-docker-compose >---------
[INFO] Building Spring Cloud Azure Docker Compose 7.1.0-beta.1
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- enforcer:3.6.2:enforce (default-cli) @ spring-cloud-azure-docker-compose ---
[INFO] Rule 0: org.apache.maven.enforcer.rules.dependency.BannedDependencies passed
[INFO] Rule 1: org.apache.maven.enforcer.rules.dependency.RequireReleaseDeps passed
[INFO]
[INFO] --- codesnippet:1.0.0-beta.10:update-codesnippet (update-codesnippets) @ spring-cloud-azure-docker-compose ---
[INFO]
[INFO] --- spotless:2.30.0:apply (spotless-apply) @ spring-cloud-azure-docker-compose ---
[INFO] Spotless apply skipped
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ spring-cloud-azure-docker-compose ---
[INFO] Copying 0 resource from src/main/resources to target/classes
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO]
[INFO] --- compiler:3.14.1:compile (default-compile) @ spring-cloud-azure-docker-compose ---
[INFO] Nothing to compile - all classes are up to date.
[INFO]
[INFO] --- compiler:3.14.1:compile (default) @ spring-cloud-azure-docker-compose ---
[INFO] Nothing to compile - all classes are up to date.
[INFO]
[INFO] --- build-helper:3.6.1:add-test-source (compile-samples-source) @ spring-cloud-azure-docker-compose ---
[INFO] Test Source directory: /home/rujche/work/git-repositories/main/azure-sdk-for-java/sdk/spring/spring-cloud-azure-docker-compose/src/samples/java added.
[INFO]
[INFO] --- build-helper:3.6.1:add-test-resource (add-properties-to-test) @ spring-cloud-azure-docker-compose ---
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ spring-cloud-azure-docker-compose ---
[INFO] Copying 5 resources from src/test/resources to target/test-classes
[INFO] Copying 0 resource from src/main/resources to target/test-classes
[INFO]
[INFO] --- compiler:3.14.1:testCompile (default-testCompile) @ spring-cloud-azure-docker-compose ---
[INFO] Nothing to compile - all classes are up to date.
[INFO]
[INFO] --- jacoco:0.8.14:prepare-agent (prepare-agent) @ spring-cloud-azure-docker-compose ---
[INFO] Skipping JaCoCo execution because property jacoco.skip is set.
[INFO]
[INFO] --- surefire:3.5.3:test (default-test) @ spring-cloud-azure-docker-compose ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
WARNING: Unknown module: com.azure.core specified to --add-opens
[INFO] Running com.azure.spring.cloud.docker.compose.implementation.service.connection.eventhubs.EventHubsDockerComposeConnectionDetailsFactoryTests
[INFO] Running com.azure.spring.cloud.docker.compose.implementation.service.connection.bus.ServiceBusDockerComposeConnectionDetailsFactoryTests
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v4.0.2)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v4.0.2)
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 242.2 s -- in com.azure.spring.cloud.docker.compose.implementation.service.connection.eventhubs.EventHubsDockerComposeConnectionDetailsFactoryTests
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 247.1 s -- in com.azure.spring.cloud.docker.compose.implementation.service.connection.bus.ServiceBusDockerComposeConnectionDetailsFactoryTests
[ERROR] Surefire is going to kill self fork JVM. The exit has elapsed 30 seconds after System.exit(0).
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:22 min
[INFO] Finished at: 2026-02-09T13:13:23+08:00
[INFO] ------------------------------------------------------------------------
rujche@RujcheThinkPad:~/work/git-repositories/main/azure-sdk-for-java$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
...ure/spring/cloud/autoconfigure/implementation/eventhubs/AzureEventHubsAutoConfiguration.java
Show resolved
Hide resolved
...re/spring/cloud/docker/compose/implementation/service/connection/hubs/eventhubs-compose.yaml
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 20 out of 22 changed files in this pull request and generated 3 comments.
...ure/spring/cloud/autoconfigure/implementation/eventhubs/AzureEventHubsAutoConfiguration.java
Show resolved
Hide resolved
.../implementation/service/connection/hubs/EventHubsContainerConnectionDetailsFactoryTests.java
Show resolved
Hide resolved
...lementation/service/connection/hubs/EventHubsDockerComposeConnectionDetailsFactoryTests.java
Show resolved
Hide resolved
…ure/azure-sdk-for-java into copilot/add-support-connectiondetails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 27 out of 29 changed files in this pull request and generated 3 comments.
...ure/spring/cloud/autoconfigure/implementation/eventhubs/AzureEventHubsAutoConfiguration.java
Show resolved
Hide resolved
.../cloud/autoconfigure/implementation/eventhubs/AzureEventHubsProducerClientConfiguration.java
Show resolved
Hide resolved
.../cloud/autoconfigure/implementation/eventhubs/AzureEventHubsConsumerClientConfiguration.java
Show resolved
Hide resolved
…heckpointStore, Producer, and Consumer configs Prevent startup failures when EventHubs auto-config activates without base-level connection info. Without these guards, configurations that constructor-inject AzureEventHubsProperties could fail with UnsatisfiedDependencyException when only sub-level properties are set. - AzureBlobCheckpointStoreConfiguration: guard against missing properties bean - AzureEventHubsProducerClientConfiguration: guard dedicated producer config - AzureEventHubsConsumerClientConfiguration: guard dedicated consumer config - Updated tests to provide AzureEventHubsPropertiesTestConfiguration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 30 out of 32 changed files in this pull request and generated no new comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 30 out of 32 changed files in this pull request and generated no new comments.
This pull request refactors the Event Hubs auto-configuration in the Spring Cloud Azure SDK to improve modularity, bean conditionality, and support for connection details. The most significant changes are the introduction of a new properties configuration module, refactoring of bean creation logic, and removal of redundant conditions and base classes.
Event Hubs Properties Configuration Refactor:
AzureEventHubsPropertiesConfiguration, which imports two new bean configuration classes:ConfigurationWithConnectionDetailsBeanandConfigurationWithoutConnectionDetailsBean. This modularizes the creation ofAzureEventHubsPropertiesbased on the presence of connection details and global properties.AzureEventHubsConnectionDetailsinterface to abstract connection string retrieval for Event Hubs, supporting integration with Spring Boot's connection details infrastructure.ConfigurationWithConnectionDetailsBeancreatesAzureEventHubsPropertieswhen a connection details bean is present, binding properties and setting the connection string from the details.ConfigurationWithoutConnectionDetailsBeanprovides a fallback configuration forAzureEventHubsPropertieswhen connection details are missing, using global properties and property binding.Bean Conditionality and Import Changes:
AzureEventHubsAutoConfigurationand related configuration classes to import the new properties configuration and rely onConditionalOnBean(AzureEventHubsProperties.class)for bean creation, removing direct property checks and base class inheritance. [1] [2] [3] [4] [5] [6] [7]StaticConnectionStringProvidertoAzureEventHubsClientBuilderConfiguration, simplifying its conditional logic and using constructor-injected properties.Removal of Redundant Conditions and Base Classes:
ConditionalOnAnyPropertyannotations from multiple configuration classes, streamlining conditional logic and relying on bean presence instead. [1] [2] [3] [4] [5] [6]AzureServiceConfigurationBaseinAzureEventHubsAutoConfigurationandAzureServiceBusAutoConfiguration, simplifying their structure. [1] [2]Service Bus Alignment:
AzureServiceBusAutoConfigurationto match the new Event Hubs configuration pattern, removing base class inheritance and redundant constructor.Miscellaneous Improvements:
These changes collectively make the auto-configuration more modular, easier to maintain, and better aligned with Spring Boot's connection details abstraction.