[BUG] Async Event Hubs Producer cannot create an Event batch to send data
See original GitHub issueDescribe 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:
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 addEventData
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
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:
- Created 4 years ago
- Comments:18 (6 by maintainers)
Thanks for providing the details. I will look into this issue and let you know.
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.
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