Search code examples
azureazure-eventhub

Azure Event hubs changing the minimum of the reciever


I'm using the EventProcessorHost to get messages off an event hub. Is there an easy way to change the maximum number of messages that are pulled off at a time. Right now the default is 10 and I know when using a normal EventReciever it is relatively easy to change the default, but I couldn't find any documentation for when using EventProcessor.

I want so when ProcessEventsAsync is called the maximum number of messages passed in to be less than 10.


Solution

  • You can do it by providing EventProcessorOptions when registering EventProcessor with MaxBatchSize property modified (https://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.eventprocessoroptions.maxbatchsize.aspx). For example:

     var eventProcessorHost = new EventProcessorHost(...);
    
     await eventProcessorHost.RegisterEventProcessorAsync<MyEventProcessor>(new EventProcessorOptions{MaxBatchSize = 5});