Delen via


ServiceBusSender.ScheduleMessageAsync Method

Definition

Schedules a message to appear on Service Bus at a later time.

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

Parameters

message
ServiceBusMessage

The ServiceBusMessage 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 the message 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).

Applies to

See also