Conversation
Added EventContextTest.updateCheckpointAsyncSetsOffsetString() which verifies that offsetString is populated on the Checkpoint passed to the store. This test fails without the fix (offsetString is null) and passes with it. Fix: added setOffsetString(eventData.getOffsetString()) in EventContext.updateCheckpointAsync(), matching the pattern already used in EventBatchContext. Fixes #46752 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
BlobCheckpointStore.updateCheckpoint() now falls back to the deprecated Checkpoint.getOffset() (Long) when getOffsetString() is null/empty, so callers that build Checkpoint instances using the legacy long offset still have the offset persisted to blob metadata. The validation guard was broadened to accept offsetString-only checkpoints. Added regression tests covering: offset fallback, offsetString preference, both populated, offsetString-only, and sequenceNumber-only. Also added a CHANGELOG entry to azure-messaging-eventhubs for the EventContext.updateCheckpointAsync() offsetString fix from the prior commit. Refs #46752 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When spring.cloud.azure.eventhubs.consumer.event-hub-name or producer.event-hub-name is configured, the autoconfiguration now selects the dedicated client builder path instead of reusing the parent EventHubClientBuilder, ensuring the override actually takes effect. Fixes #43593 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Azure Spring Event Hubs autoconfiguration so that sub-level event-hub-name overrides (under spring.cloud.azure.eventhubs.consumer / .producer) correctly trigger the dedicated builder path, ensuring producer/consumer clients connect to the overridden hub rather than the base hub. It also includes a separate checkpointing fix in the Event Hubs libraries to ensure offsetString is propagated and persisted correctly.
Changes:
- Spring autoconfigure: route to dedicated consumer/producer configuration when sub-level
event-hub-nameis set, and add regression tests for the override scenario. - Event Hubs client: propagate
EventData.offsetStringintoCheckpointinEventContext.updateCheckpointAsync()(with a regression unit test). - Blob checkpoint store: prefer
Checkpoint.offsetString, and fall back to deprecatedCheckpoint.offsetwhenoffsetStringis missing (with expanded unit coverage + changelog updates).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/eventhubs/AzureEventHubsProducerClientConfiguration.java | Ensures sub-level producer event-hub-name triggers the dedicated configuration path. |
| sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/eventhubs/AzureEventHubsConsumerClientConfiguration.java | Ensures sub-level consumer event-hub-name triggers the dedicated configuration path. |
| sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/implementation/eventhubs/AzureEventHubsProducerClientConfigurationTests.java | Adds a regression test asserting dedicated config is used when producer event-hub-name overrides the base value. |
| sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/implementation/eventhubs/AzureEventHubsConsumerClientConfigurationTests.java | Adds a regression test asserting dedicated config is used when consumer event-hub-name overrides the base value. |
| sdk/spring/spring-cloud-azure-autoconfigure/CHANGELOG.md | Documents the Spring Event Hubs override bug fix (#43593). |
| sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/models/EventContext.java | Propagates EventData.offsetString into the checkpoint built by updateCheckpointAsync(). |
| sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/models/EventContextTest.java | Adds a regression test verifying offsetString is set on the checkpoint passed to CheckpointStore. |
| sdk/eventhubs/azure-messaging-eventhubs/CHANGELOG.md | Documents the EventContext.updateCheckpointAsync() checkpointing fix (#46752). |
| sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/main/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobCheckpointStore.java | Updates validation and persistence to prefer offsetString and fall back to deprecated offset. |
| sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/src/test/java/com/azure/messaging/eventhubs/checkpointstore/blob/BlobCheckpointStoreTests.java | Adds unit tests covering fallback/preference/validation behaviors for offsetString vs offset. |
| sdk/eventhubs/azure-messaging-eventhubs-checkpointstore-blob/CHANGELOG.md | Documents the Blob checkpoint store fallback fix (#46752). |
Comment on lines
+11
to
+15
| - Fixed `EventContext.updateCheckpointAsync()` so that the `offsetString` from the received `EventData` is propagated | ||
| to the `Checkpoint` passed to the `CheckpointStore`. Previously only the deprecated `offset` (Long) was set, which | ||
| caused checkpoint stores that read `offsetString` (such as `BlobCheckpointStore`) to persist a `null` offset, breaking | ||
| partition switch-over and consumer-group lag monitoring. | ||
| ([#46752](https://github.com/Azure/azure-sdk-for-java/issues/46752)) |
| } | ||
|
|
||
| /** | ||
| * Tests that an offsetString-only checkpoint is accepted by the validation guard (preserving previous behavior). |
Comment on lines
244
to
252
| @Override | ||
| public Mono<Void> updateCheckpoint(Checkpoint checkpoint) { | ||
| if (checkpoint == null || (checkpoint.getSequenceNumber() == null && checkpoint.getOffset() == null)) { | ||
| if (checkpoint == null | ||
| || (checkpoint.getSequenceNumber() == null | ||
| && checkpoint.getOffset() == null | ||
| && CoreUtils.isNullOrEmpty(checkpoint.getOffsetString()))) { | ||
| throw LOGGER.logExceptionAsWarning(Exceptions.propagate(new IllegalStateException( | ||
| "Both sequence number and offset cannot be null when updating a checkpoint"))); | ||
| "At least one of sequence number, offset, or offsetString must be provided when updating a checkpoint"))); | ||
| } |
rujche
reviewed
May 7, 2026
Member
|
/azp run java - spring - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
rujche
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #43593.
Problem
When using
spring-cloud-azure-starter-eventhubswith both base-level and sub-levelevent-hub-nameconfigured:the injected
EventHubProducerClient/EventHubConsumerClientconnect tobbbbinstead of the overrideaaaa.Root cause
The property merge in
AzureEventHubsProperties.build{Consumer,Producer}Properties()is correct (sub-level wins). The defect is in the autoconfiguration path selection:AzureEventHubs{Consumer,Producer}ClientConfigurationonly switches to the Dedicated (per-section builder) inner configuration whenconnection-stringornamespaceis set under the sub-prefix. With onlyevent-hub-nameoverridden, it falls through to the Shared configuration, which reuses the parentEventHubClientBuilderalready pinned tobbbb.EventHubClientBuilderis per-hub, so the shared path cannot represent a different hub.Fix
Add
"event-hub-name"to the@ConditionalOnMissingProperty/@ConditionalOnAnyPropertynamearrays in both consumer and producer client configurations. Any sub-levelevent-hub-nameoverride now routes to the Dedicated path, which already callsbuild{Consumer,Producer}Properties()with the correct precedence — no merge-logic changes required.Tests
consumerEventHubNameOverrideShouldConfigureDedicatedandproducerEventHubNameOverrideShouldConfigureDedicatedreproducing the issue scenario and asserting the merged properties resolve to the override and to the parent namespace.eventHubNameAndConsumerGroupProvidedShouldConfigure/eventHubNameProvidedShouldConfigurethat were asserting the old (buggy) behavior of no inner config being created when onlyconsumer.event-hub-name/producer.event-hub-namewas set.spring-cloud-azure-autoconfigurepass locally.How to verify