Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

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:

  • Introduced AzureEventHubsPropertiesConfiguration, which imports two new bean configuration classes: ConfigurationWithConnectionDetailsBean and ConfigurationWithoutConnectionDetailsBean. This modularizes the creation of AzureEventHubsProperties based on the presence of connection details and global properties.
  • Added AzureEventHubsConnectionDetails interface to abstract connection string retrieval for Event Hubs, supporting integration with Spring Boot's connection details infrastructure.
  • ConfigurationWithConnectionDetailsBean creates AzureEventHubsProperties when a connection details bean is present, binding properties and setting the connection string from the details.
  • ConfigurationWithoutConnectionDetailsBean provides a fallback configuration for AzureEventHubsProperties when connection details are missing, using global properties and property binding.

Bean Conditionality and Import Changes:

  • Refactored AzureEventHubsAutoConfiguration and related configuration classes to import the new properties configuration and rely on ConditionalOnBean(AzureEventHubsProperties.class) for bean creation, removing direct property checks and base class inheritance. [1] [2] [3] [4] [5] [6] [7]
  • Moved the creation of StaticConnectionStringProvider to AzureEventHubsClientBuilderConfiguration, simplifying its conditional logic and using constructor-injected properties.

Removal of Redundant Conditions and Base Classes:

  • Removed ConditionalOnAnyProperty annotations from multiple configuration classes, streamlining conditional logic and relying on bean presence instead. [1] [2] [3] [4] [5] [6]
  • Eliminated inheritance from AzureServiceConfigurationBase in AzureEventHubsAutoConfiguration and AzureServiceBusAutoConfiguration, simplifying their structure. [1] [2]

Service Bus Alignment:

  • Updated AzureServiceBusAutoConfiguration to match the new Event Hubs configuration pattern, removing base class inheritance and redundant constructor.

Miscellaneous Improvements:

  • Added missing imports and annotations to ensure correct conditional bean creation and property binding throughout the refactored configuration files. [1] [2] [3]

These changes collectively make the auto-configuration more modular, easier to maintain, and better aligned 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 19 out of 19 changed files in this pull request and generated 2 comments.

@rujche rujche marked this pull request as ready for review February 9, 2026 06:55
@rujche rujche requested review from a team, Netyyyy, moarychan and saragluna as code owners February 9, 2026 06:55
@rujche rujche requested a review from Copilot February 9, 2026 06:55
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 20 out of 22 changed files in this pull request and generated 3 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 27 out of 29 changed files in this pull request and generated 3 comments.

…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
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 30 out of 32 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 30 out of 32 changed files in this pull request and generated no new comments.

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: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants