Skip to content

[BUG] When trying to connect to eventhub using connection string, the EventProcessorClient fails for Emulator #40938

Description

@gayanper

Describe the bug
When trying to connect to Eventhub Emulator using connection string

It fails to make the connection since the EventProcessorClient tries to connect to secured AMQP port instead of the non secure one. The reason for this the connection string is not copied at the location

EventHubClientBuilder com.azure.messaging.eventhubs.EventProcessorClientBuilder.copyOptions(EventHubClientBuilder source)

Exception or Stack Trace

2024-06-30T12:25:16.826+02:00  INFO 78341 --- [eventhub-demo] [ctor-executor-1] c.a.c.a.i.handler.ConnectionHandler      : {"az.sdk.message":"onConnectionBound","connectionId":"MF_ed25eb_1719743116547","hostName":"127.0.0.1","peerDetails":"127.0.0.1:5671"}

To Reproduce
Use the steps to spin up a Emulator instance with instructions at https://github.com/Azure/azure-event-hubs-emulator-installer/tree/main

Using the following code snippet to make a connection to the eventhub.

Code Snippet

		BlobContainerAsyncClient client = new BlobContainerClientBuilder().connectionString(
"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1").containerName("eh1").buildAsyncClient();
		client.createIfNotExists().block();
		

		var eventProcessorClient =  new EventProcessorClientBuilder().connectionString("Endpoint=sb://127.0.0.1;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;", hubName).checkpointStore(
		        new BlobCheckpointStore(client)).processEvent(event -> System.out.println(event)).processError(
		                error -> System.out.println(error)).consumerGroup("cg1").buildEventProcessorClient();

		eventProcessorClient.start();

Expected behavior
When the connection string is given, use the connection string information to initialize the connection options in the copy of the EventHubClientBuilder.

Setup (please complete the following information):

  • OS: MacOS
  • IDE: VSCode
  • Library/Libraries: [com.azure:azure-messaging-eventhubs:5.18.5, com.azure:azure-messaging-eventhubs-checkpointstore-blob:1.19.5<]
  • Java version: [22]
  • App Server/Environment: [Tomcat]
  • Frameworks: [Spring Boot]

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Metadata

Metadata

Assignees

Labels

Event Hubscustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions