public async Task Schedule() { var sender = new ServiceBusSenderClient(ConnString, QueueName); var scheduleTime = DateTimeOffset.UtcNow.AddHours(10); var sequenceNum = await sender.ScheduleMessageAsync(GetMessage(), scheduleTime); var receiver = new QueueReceiverClient(ConnString, QueueName); ServiceBusMessage msg = await receiver.PeekBySequenceAsync(sequenceNum); Assert.AreEqual(0, Convert.ToInt32(new TimeSpan(scheduleTime.Ticks - msg.ScheduledEnqueueTimeUtc.Ticks).TotalSeconds)); await sender.CancelScheduledMessageAsync(sequenceNum); msg = await receiver.PeekBySequenceAsync(sequenceNum); Assert.IsNull(msg); }
public async Task Schedule() { await using (var scope = await ServiceBusScope.CreateWithQueue(enablePartitioning: false, enableSession: false)) { await using var sender = new ServiceBusSenderClient(TestEnvironment.ServiceBusConnectionString, scope.QueueName); var scheduleTime = DateTimeOffset.UtcNow.AddHours(10); var sequenceNum = await sender.ScheduleMessageAsync(GetMessage(), scheduleTime); await using var receiver = new ServiceBusReceiverClient(TestEnvironment.ServiceBusConnectionString, scope.QueueName); ServiceBusMessage msg = await receiver.PeekBySequenceAsync(sequenceNum); Assert.AreEqual(0, Convert.ToInt32(new TimeSpan(scheduleTime.Ticks - msg.ScheduledEnqueueTimeUtc.Ticks).TotalSeconds)); await sender.CancelScheduledMessageAsync(sequenceNum); msg = await receiver.PeekBySequenceAsync(sequenceNum); Assert.IsNull(msg); } }