Udostępnij za pośrednictwem


ServiceBusMessageBatch.TryAddMessage(ServiceBusMessage) Method

Definition

Attempts to add a message to the batch, ensuring that the size of the batch does not exceed its maximum.

public bool TryAddMessage (Azure.Messaging.ServiceBus.ServiceBusMessage message);
member this.TryAddMessage : Azure.Messaging.ServiceBus.ServiceBusMessage -> bool
Public Function TryAddMessage (message As ServiceBusMessage) As Boolean

Parameters

message
ServiceBusMessage

The message to attempt to add to the batch.

Returns

true if the message was added; otherwise, false.

Exceptions

When a batch is sent, it will be locked for the duration of that operation. During this time, no messages may be added to the batch. Calling TryAdd while the batch is being sent will result in an InvalidOperationException until the send has completed.

Occurs when the message has a member in its ApplicationProperties collection that is an unsupported type for serialization. See the ApplicationProperties remarks for details.

Remarks

When a message is accepted into the batch, changes made to its properties will not be reflected in the batch nor will any state transitions be reflected to the original instance.

Note: Any ReadOnlyMemory<T>, byte array, or BinaryData instance associated with the event is referenced by the batch and must remain valid and unchanged until the batch is disposed.

Applies to