ServiceBusModelFactory.ServiceBusMessageBatch Method

Definition

Initializes a new instance of the ServiceBusMessageBatch class.

public static Azure.Messaging.ServiceBus.ServiceBusMessageBatch ServiceBusMessageBatch (long batchSizeBytes, System.Collections.Generic.IList<Azure.Messaging.ServiceBus.ServiceBusMessage> batchMessageStore, Azure.Messaging.ServiceBus.CreateMessageBatchOptions batchOptions = default, Func<Azure.Messaging.ServiceBus.ServiceBusMessage,bool> tryAddCallback = default);
static member ServiceBusMessageBatch : int64 * System.Collections.Generic.IList<Azure.Messaging.ServiceBus.ServiceBusMessage> * Azure.Messaging.ServiceBus.CreateMessageBatchOptions * Func<Azure.Messaging.ServiceBus.ServiceBusMessage, bool> -> Azure.Messaging.ServiceBus.ServiceBusMessageBatch
Public Shared Function ServiceBusMessageBatch (batchSizeBytes As Long, batchMessageStore As IList(Of ServiceBusMessage), Optional batchOptions As CreateMessageBatchOptions = Nothing, Optional tryAddCallback As Func(Of ServiceBusMessage, Boolean) = Nothing) As ServiceBusMessageBatch

Parameters

batchSizeBytes
Int64

The size, in bytes, that the batch should report; this is a static value and will not mutate as messages are added.

batchMessageStore
IList<ServiceBusMessage>

A list to which messages will be added when TryAddMessage(ServiceBusMessage) calls are successful.

batchOptions
CreateMessageBatchOptions

The set of options to consider when creating this batch.

tryAddCallback
Func<ServiceBusMessage,Boolean>

A function that will be invoked when TryAddMessage(ServiceBusMessage) is called; the return of this callback represents the result of TryAddMessage(ServiceBusMessage). If not provided, all events will be accepted into the batch.

Returns

The ServiceBusMessageBatch instance that was created.

Remarks

The batch instance keeps an internal copy of events successfully added to the batch through TryAddMessage(ServiceBusMessage), meaning that any changes made to batchMessageStore after adding the messages to the batch will not be reflected.

Applies to