Partilhar via


ServiceBusSender.ScheduleMessagesAsync Method

Definition

Schedules a set of messages to appear on Service Bus at a later time.

public virtual System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<long>> ScheduleMessagesAsync (System.Collections.Generic.IEnumerable<Azure.Messaging.ServiceBus.ServiceBusMessage> messages, DateTimeOffset scheduledEnqueueTime, System.Threading.CancellationToken cancellationToken = default);
abstract member ScheduleMessagesAsync : seq<Azure.Messaging.ServiceBus.ServiceBusMessage> * DateTimeOffset * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<int64>>
override this.ScheduleMessagesAsync : seq<Azure.Messaging.ServiceBus.ServiceBusMessage> * DateTimeOffset * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<int64>>
Public Overridable Function ScheduleMessagesAsync (messages As IEnumerable(Of ServiceBusMessage), scheduledEnqueueTime As DateTimeOffset, Optional cancellationToken As CancellationToken = Nothing) As Task(Of IReadOnlyList(Of Long))

Parameters

messages
IEnumerable<ServiceBusMessage>

The set of messages to schedule.

scheduledEnqueueTime
DateTimeOffset

The UTC time at which the message should be available for processing

cancellationToken
CancellationToken

An optional CancellationToken instance to signal the request to cancel the operation.

Returns

The sequence number of the message that was scheduled.

Exceptions

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

Remarks

Although the message will not be available to be received until the scheduledEnqueueTime, it can still be peeked before that time. Messages can also be scheduled by setting ScheduledEnqueueTime and using SendMessageAsync(ServiceBusMessage, CancellationToken), SendMessagesAsync(IEnumerable<ServiceBusMessage>, CancellationToken), or SendMessagesAsync(ServiceBusMessageBatch, CancellationToken).

When scheduling, the result is atomic; either all messages that belong to the set were successful or all have failed. Partial success is not possible.

Applies to

See also