How can the serialized size of EventData be determined for batching?

后端 未结 1 1554
庸人自扰
庸人自扰 2021-01-15 05:52

In the documentation for the Azure EventHubClient there are two methods for sending a batch of data each of them has the remark below and will throw a MessageSizeExceededExc

相关标签:
1条回答
  • 2021-01-15 06:56

    ----Updating after the Nuget Update---- Here's the EventData property - SerializedSizeInBytes that we introduced in our recent SDK iteration - which addresses this specific problem - available in all sdk nugets above 2.6 .

    ---Update after EventDataBatch utility---

    use EventDataBatch.TryAdd(EventData) API to construct the batch. When the EventData cannot fit into the batch - this API will return false. Stop adding more events & then use the sender (EventHubClient or PartitionSender) to send the EventDataBatch.

    following considerations motivated us to design EventDataBatch API:

    • Help developers using our Client API - to deal with size of batch of EventData
    • Abstract out region-wide/SKU-based MaximumMessageSize configuration: EventHubs service across the world could have different Max EventData sizes - across different EventHub regions and different SKUs of EventHub. We wanted to expose a uniform way for developers to construct maximum message size for any given environment. So, when EventDataBatch is initialized using eventHubClient.createBatch() API - the client negotiates batchSize with EventHubs Service and returns the EventDataBatch instance which can construct the correct size!

    HTH! Sree

    0 讨论(0)
提交回复
热议问题