Skip to content

Comments

Add ConnectionDetails support for EventHubs#47926

Merged
rujche merged 33 commits intomainfrom
copilot/add-support-connectiondetails
Feb 12, 2026
Merged

Add ConnectionDetails support for EventHubs#47926
rujche merged 33 commits intomainfrom
copilot/add-support-connectiondetails

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

This pull request refactors the Event Hubs and Cosmos auto-configuration in the Spring Cloud Azure SDK to simplify configuration, improve modularity, and enable support for connection details beans. The changes remove legacy base classes and property-loading logic, introduce new configuration classes, and update conditional annotations to ensure beans are only created when appropriate properties or beans are present.

Event Hubs auto-configuration refactoring:

  • Removed inheritance from AzureServiceConfigurationBase and manual property loading in AzureEventHubsAutoConfiguration, now relying on AzureEventHubsPropertiesConfiguration for property setup.
  • Introduced AzureEventHubsPropertiesConfiguration to handle property beans and support both connection string and connection details beans.
  • Updated AzureEventHubsClientBuilderConfiguration to import AzureEventHubsPropertiesConfiguration, require AzureEventHubsProperties bean, and add support for AzureEventHubsConnectionDetails beans. [1] [2]
  • Added new interface AzureEventHubsConnectionDetails for connection details beans, enabling more flexible connection configuration.

Conditional bean creation improvements:

  • Replaced various @ConditionalOnAnyProperty annotations with @ConditionalOnBean(AzureEventHubsProperties.class) in Event Hubs-related configuration classes to ensure beans are only created when relevant properties are present. [1] [2] [3] [4] [5]
  • Added conditional bean creation for connection details in Kafka auto-configuration, including validation of connection strings.

Cosmos auto-configuration simplification:

  • Removed inheritance from AzureServiceConfigurationBase and property-loading logic in AzureCosmosAutoConfiguration, simplifying the class.

Cleanup and removal of legacy code:

  • Removed unused imports and legacy property-loading code from multiple files, streamlining the configuration classes. [1] [2] [3]
  • Removed unnecessary inner classes and conditions from processor client configuration.

These changes make the auto-configuration more modular, easier to maintain, and compatible with Spring Boot's connection details abstraction.

Copilot AI and others added 2 commits February 6, 2026 07:56
…ners, and docker-compose

Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for ConnectionDetails in EventHubs Add ConnectionDetails support for EventHubs Feb 6, 2026
Copilot AI requested a review from rujche February 6, 2026 08:08
@rujche rujche requested a review from Copilot February 6, 2026 09:05
@rujche rujche added azure-spring All azure-spring related issues azure-spring-eventhubs-kafka Spring event hubs kafka related issues. labels Feb 6, 2026
@rujche rujche moved this from Todo to In Progress in Spring Cloud Azure Feb 6, 2026
@rujche rujche added this to the 2026-02 milestone Feb 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

API Change Check

APIView identified API level changes in this PR and created the following API reviews

com.azure.spring:spring-cloud-azure-docker-compose
com.azure.spring:spring-cloud-azure-testcontainers

Copy link
Contributor

Copilot AI left a 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

@rujche
Copy link
Member

rujche commented Feb 9, 2026

EventHubsDockerComposeConnectionDetailsFactoryTests passed in wsl now

Here 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$

Copy link
Contributor

Copilot AI left a 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 31 out of 33 changed files in this pull request and generated no new comments.

Copy link
Contributor

Copilot AI left a 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 32 out of 34 changed files in this pull request and generated 1 comment.

Copy link
Contributor

Copilot AI left a 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 36 out of 38 changed files in this pull request and generated no new comments.

Copy link
Contributor

Copilot AI left a 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 36 out of 38 changed files in this pull request and generated no new comments.

@rujche
Copy link
Member

rujche commented Feb 11, 2026

/azp run java - spring - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@saragluna saragluna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@rujche
Copy link
Member

rujche commented Feb 12, 2026

/check-enforcer override

@rujche
Copy link
Member

rujche commented Feb 12, 2026

Ignore the failures in java - spring - tests, it's not caused by current PR, in main branch, it also failed. https://dev.azure.com/azure-sdk/internal/_build?definitionId=1760&_a=summary&repositoryFilter=30&branchFilter=127780%2C127780%2C127780%2C127780%2C127780%2C127780%2C127780%2C127780%2C127780%2C127780%2C127780%2C127780%2C127780

image

Will fix the failure in another PR.

@rujche rujche merged commit ba63ffc into main Feb 12, 2026
80 of 84 checks passed
@rujche rujche deleted the copilot/add-support-connectiondetails branch February 12, 2026 01:27
@github-project-automation github-project-automation bot moved this from In Progress to Done in Spring Cloud Azure Feb 12, 2026
Netyyyy pushed a commit to Netyyyy/azure-sdk-for-java that referenced this pull request Feb 14, 2026
@Netyyyy Netyyyy mentioned this pull request Feb 14, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azure-spring All azure-spring related issues azure-spring-eventhubs-kafka Spring event hubs kafka related issues.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants