你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

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