ServiceBusSender.ScheduleMessageAsync(ServiceBusMessage, DateTimeOffset, CancellationToken) 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
System.DateTimeOffset

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

cancellationToken
System.Threading.CancellationToken

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

Returns

System.Threading.Tasks.Task<System.Int64>

The sequence number of the message that was scheduled.

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