Starting in version 15.1, batch processing support has been added. Batch processing can be useful in scenarios where you need to aggregate a number of messages prior to performing an operation, or, to allow parallel processing of messages.
There are two requirements to enable batch processing:
- Change the queue operation to 'batch' mode.
- Implement the IBatchDevice interface in your custom device
public interface IBatchDevice { /// <summary> /// This method is called by the channel when 1, or more messages are ready to be processed by a device. /// The device can decide the order, and threading policy, the messages are processed in. /// Batch processing must be enabled on the Queue. /// Implementors should also implement ProcessMessageAsync to allow for when the /// Batch processing is disabled on the Queue. /// </summary> /// <param name="batchContext">The context contain the message to be processed</param> /// <param name="cancellationToken">A token that can be checked to see if the channel has been stopped</param> Task ProcessMessagesAsync(IMessageBatchContext batchContext, CancellationToken cancellationToken); }