I have the following pattern,
Http Trigger Function App -> Event Hub -> Event Hub Listener Function App
Unfortunately, the sender to the HTTP Trigger app sends many individual requests, meaning that the execution of the send to event hub is also a small amount of data per message.
This causes the listener to trigger on every small message, creating many, many files at the end of a data load.
My listener is already configured to receive batch events, and I have seen in the past, that when the listener function was disabled for a while, and then re-enabled, the data would be received in a big batch.
How can I ensure that multiple events are processed in a batch once it gets to the listener, even though their send to the event hub are as individual requests/messages?
Is there some delay setting for the listener, perhaps?
2
Answers
The
MaxBatchSize
parameter of theEventProcessorOptions
object can be used to receive events in a batch.To receive events as a batch, you can use the
MaxBatchSize
property of theEventProcessorOptions
object.Reference :
Thank for the reference @ciaranodonnell
Sending Message:
Receiving Message :
Output :
Reference :
There’s not enough context available to understand how the
maxEventBatchSize
is configured in yourhost.json
, but I’ll assume that is set to something larger than 1. In that case, it sounds like the partitions do not have a backlog of events and are being read as they arrive. Since there are not enough events to keep the prefetch queue full, events are being dispatched as they stream in.I’d recommend taking advantage of the
minEventBatchSize
that was added in v5.3.0 of the Event Hubs trigger. This works withmaxWaitTime
to ask the trigger to wait for a bit and build up a batch rather its default behavior of preferring to maximize throughput.A minimal example would look something like:
More detail is available in the host.json settings section of the docs.