Beispiel #1
0
            static async Task <bool> ScheduleSend(SendEndpointContext clientContext, AzureServiceBusSendContext <T> context)
            {
                var now = DateTime.UtcNow;

                var enqueueTimeUtc = context.ScheduledEnqueueTimeUtc.Value;

                if (enqueueTimeUtc < now)
                {
                    LogContext.Debug?.Log("The scheduled time was in the past, sending: {ScheduledTime}", context.ScheduledEnqueueTimeUtc);

                    return(false);
                }

                try
                {
                    var brokeredMessage = CreateBrokeredMessage(context);

                    var sequenceNumber = await clientContext.ScheduleSend(brokeredMessage, enqueueTimeUtc).ConfigureAwait(false);

                    context.SetScheduledMessageId(sequenceNumber);

                    context.LogScheduled(enqueueTimeUtc);

                    return(true);
                }
                catch (ArgumentOutOfRangeException)
                {
                    LogContext.Debug?.Log("The scheduled time was rejected by the server, sending: {MessageId}", context.MessageId);

                    return(false);
                }
            }
 Task <long> SendEndpointContext.ScheduleSend(Message message, DateTime scheduleEnqueueTimeUtc)
 {
     return(_context.ScheduleSend(message, scheduleEnqueueTimeUtc));
 }