azure-sdk-for-java: [BUG] Event Hubs: Enqueueing events hangs when having multiple connections to multiple-partition hub
Description In Event Hubs, when opening multiple connections to a multiple-partition hub, and trying to enqueue an event with each connection, none of the enqueue or batch success or failure handler are called.
To Reproduce
- Create a buffered producer client builder, specifying a hub with multiple partitions, e.g. 19.
- In a long loop, e.g. 10 times, do the following each time:
- Use the builder to create an async client.
- Create event data.
- Use the client to enqueue the event, specifying a partition Id in the send options.
Code Snippet
EventHubBufferedProducerClientBuilder builder = new EventHubBufferedProducerClientBuilder()
.onSendBatchSucceeded(this::onBatchSucceed)
.onSendBatchFailed(this::onBatchFailed)
.connectionString(connectionString, hubName);
for (int i = 0; i < 10; i++) {
EventHubBufferedProducerAsyncClient producerClient = builder.buildAsyncClient();
EventData eventData = new EventData(("data_0").getBytes()).setMessageId("id_0");
producerClient.enqueueEvent(eventData, new SendOptions().setPartitionId("0")).subscribe(
numberOfEvents -> {
System.out.printf("There are %d events in the buffer.%n", numberOfEvents);
}, error -> {
System.err.println("Error occurred enqueueing events: " + error);
},
() -> {
System.out.println("Event successfully enqueued.");
});
}
More Info In file EventHubBufferedPartitionProducer.java, in function createNewBatch, on one of the first times the function is called, the call to the method get hangs indefinitely. Experimentally adding a timeout to it and (re-building the SDK) enables successful enqueueing and publishing of most, but not all events.
Setup
- OS: Windows Server 2016
- IDE: IntelliJ IDEA 2024.1.4
- SDK: 5.20.0-beta.1
- Library: com.azure:azure-core:1.54.1
- Java version: 17
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 16 (11 by maintainers)
Thanks! I’ll take a look.