question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Async Event Hubs Producer cannot create an Event batch to send data

See original GitHub issue

Describe the bug

I’m following the guide here to create an EventHubProducerAsyncClient – which is different than the EventHubProducerCluent used in the documentation. When I try creating an EventDataBatch to send my data, I get the error:

Screen Shot 2020-03-05 at 11 50 36 AM

Looking more into the error it seems that EventHubProducerClient is a wrapper on top of EventHubProducerAsyncClient and it uses the library Mono to convert the Mono object returned from EventHubProducerAsycClient.createBatch() to EventDataBatch. But if I try to createBatch() directly from the Async Producer Client I’m unable to cast it into an EventDataBatch.

Exception or Stack Trace

.../test-event-hub-producer/src/main/java/EventHubProducerMain.java:[18,60] incompatible types: reactor.core.publisher.Mono<com.azure.messaging.eventhubs.EventDataBatch> cannot be converted to com.azure.messaging.eventhubs.EventDataBatch

To Reproduce

  • Create an EventHubProducerAsyncClient with the proper connection string and Event Hubs name. More info here.
  • Try to create an EventDataBatch to add EventData objects to the batch. Get the error in the screenshot above.

Code Snippet

EventHubProducerAsyncClient eventHubProducer = new EventHubClientBuilder().connectionString(connectionString, eventHubName).buildAsyncProducerClient();
EventDataBatch batch = eventHubProducer.createBatch();

Expected behavior

eventHubProducer.createBatch() should return EventDataBatch type or another compatible type which can be casted into EventDataBatch.

Screenshots

Screen Shot 2020-03-05 at 11 50 36 AM

Setup (please complete the following information):

  • OS: macOS X
  • IDE : IntelliJ
  • Version of the Library used: 5.0.2

Additional context

I’m using the following dependency in my pom.xml:

        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-messaging-eventhubs</artifactId>
            <version>5.0.2</version>
        </dependency>

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
srnagarcommented, Mar 11, 2020

Thanks for providing the details. I will look into this issue and let you know.

0reactions
Yasara-Ycommented, Aug 3, 2022

Hi @srnagar @aaronkorver , I am experiencing the same error when trying to create an event batch to send data and the error trace is as follows.

Timeout on blocking read for 60000000000 NANOSECONDS java.lang.IllegalStateException: Timeout on blocking read for 60000000000 NANOSECONDS| 
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:123) ~[reactor-core-3.4.12.jar:3.4.12]| 
at reactor.core.publisher.Mono.block(Mono.java:1731) ~[reactor-core-3.4.12.jar:3.4.12]| 
at com.azure.messaging.eventhubs.EventHubProducerClient.createBatch(EventHubProducerClient.java:128) ~[azure-messaging-eventhubs-5.7.0.jar:?]| 

But some batches are created successfully and published to eventhub. Only some events drop when trying to create a batch. Can you please shed some light on how to resolve this issue?

Created a new issue https://github.com/Azure/azure-sdk-for-java/issues/30256

Read more comments on GitHub >

github_iconTop Results From Across the Web

Send or receive events from Azure Event Hubs using .NET ...
Add events to the batch using the EventDataBatch.TryAdd method. Sends the batch of messages to the event hub using the EventHubProducerClient.
Read more >
Java send to EventHub (not shutting down gracefully)
I tried using an async approach which seems to work fine but creating a new connection for each data to be sent seems...
Read more >
Overview (Azure SDK for Java Reference Documentation) - NET
Package containing classes used for creating and configuring events that are being sent-to and received-from Azure Event Hubs service.
Read more >
Azure.Messaging.EventHubs 5.7.0-beta.3 - NuGet
The best approach for resolving this error is to reduce the number of events being sent in a batch or the size of...
Read more >
@azure/event-hubs - npm
The Azure Event Hubs client library allows you to send and receive events in your ... An Event Hub producer is a source...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found