Skip to content
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

Enabling v2 stack as the default for Event Hubs #43725

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/eventhubs/azure-messaging-eventhubs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Features Added

Setting the v2 stack as the default. ([43725](https://github.com/Azure/azure-sdk-for-java/pull/43725))

### Breaking Changes

- Do not remove `x-opt-partition-key` message annotation when publishing events.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class V2StackSupport {
private static final ConfigurationProperty<Boolean> V2_STACK_PROPERTY
= ConfigurationPropertyBuilder.ofBoolean(V2_STACK_KEY)
.environmentVariableName(V2_STACK_KEY)
.defaultValue(false)
.defaultValue(true)
.shared(true)
.build();
private final AtomicReference<Boolean> v2StackFlag = new AtomicReference<>();
Expand All @@ -62,7 +62,7 @@ final class V2StackSupport {
* @return true if the clients should use the v2 stack.
*/
boolean isV2StackEnabled(Configuration configuration) {
return isOptedIn(configuration, V2_STACK_PROPERTY, v2StackFlag);
return !isOptedOut(configuration, V2_STACK_PROPERTY, v2StackFlag);
}

/**
Expand Down Expand Up @@ -113,33 +113,6 @@ private boolean isOptedOut(Configuration configuration, ConfigurationProperty<Bo
return choiceFlag.get();
}

private boolean isOptedIn(Configuration configuration, ConfigurationProperty<Boolean> configProperty,
AtomicReference<Boolean> choiceFlag) {
final Boolean flag = choiceFlag.get();
if (flag != null) {
return flag;
}

final String propName = configProperty.getName();
final boolean isOptedIn;
if (configuration != null) {
isOptedIn = configuration.get(configProperty);
} else {
assert !CoreUtils.isNullOrEmpty(propName);
if (!CoreUtils.isNullOrEmpty(System.getenv(propName))) {
isOptedIn = "true".equalsIgnoreCase(System.getenv(propName));
} else if (!CoreUtils.isNullOrEmpty(System.getProperty(propName))) {
isOptedIn = "true".equalsIgnoreCase(System.getProperty(propName));
} else {
isOptedIn = false;
}
}
if (choiceFlag.compareAndSet(null, isOptedIn)) {
logger.verbose("Selected configuration {}={}", propName, isOptedIn);
}
return choiceFlag.get();
}

ReactorConnectionCache<EventHubReactorAmqpConnection> createConnectionCache(ConnectionOptions connectionOptions,
Supplier<String> eventHubNameSupplier, MessageSerializer serializer, Meter meter,
boolean useSessionChannelCache) {
Expand Down
Loading