Skip to content

fix(azure): correct EventHubs emulator test client builder usage#11835

Open
kiview wants to merge 1 commit into
mainfrom
fix/azure-eventhubs-emulator-test
Open

fix(azure): correct EventHubs emulator test client builder usage#11835
kiview wants to merge 1 commit into
mainfrom
fix/azure-eventhubs-emulator-test

Conversation

@kiview
Copy link
Copy Markdown
Member

@kiview kiview commented Jun 8, 2026

Problem

EventHubsEmulatorContainerTest.testWithEventHubsClient() was failing with:

AmqpException: The messaging entity 'sb://emulatorns1.eventhubs.emulator.net/eh1' could not be found.

The test called both .connectionString(emulator.getConnectionString()) and .fullyQualifiedNamespace("emulatorNs1") on EventHubClientBuilder. In the Azure SDK these two methods are mutually exclusive — .fullyQualifiedNamespace() overrides the endpoint from the connection string, causing the SDK to resolve emulatorNs1.eventhubs.emulator.net instead of the mapped localhost port.

Fix

Replace the broken chained calls with the two-arg connectionString(connectionString, eventHubName) overload, which correctly sets both the endpoint and entity name:

// Before (broken)
new EventHubClientBuilder()
    .connectionString(emulator.getConnectionString())
    .fullyQualifiedNamespace("emulatorNs1")  // overrides localhost endpoint!
    .eventHubName("eh1")
    .buildProducerClient();

// After (fixed)
new EventHubClientBuilder()
    .connectionString(emulator.getConnectionString(), "eh1")
    .buildProducerClient();

The emulator container implementation and config file (eventhubs_config.json) are correct and unchanged.

…emulator test

The EventHubClientBuilder.fullyQualifiedNamespace() call overrides the
endpoint set by connectionString(), causing the SDK to resolve
'emulatorNs1' as a DNS hostname (emulatorNs1.eventhubs.emulator.net)
instead of using the localhost endpoint from the connection string.

Use the two-arg connectionString(connectionString, eventHubName) overload
instead, which correctly sets both the endpoint (from the connection
string) and the entity name without replacing the endpoint.
@kiview kiview requested a review from a team as a code owner June 8, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant