azure-sdk-for-java: [BUG] Async Event Hubs Producer cannot create an Event batch to send data

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

About this issue

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

Most upvoted comments

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