Task <ScheduledMessage <T> > IMessageScheduler.ScheduleSend <T>(Uri destinationAddress, DateTime scheduledTime, T message,
                                                                        CancellationToken cancellationToken)
        {
            if (destinationAddress == null)
            {
                throw new ArgumentNullException(nameof(destinationAddress));
            }
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            var pipeProxy = new ServiceBusScheduleMessagePipe <T>(scheduledTime);

            return(ScheduleSend(destinationAddress, scheduledTime, message, pipeProxy, cancellationToken));
        }
        Task <ScheduledMessage <T> > IMessageScheduler.ScheduleSend <T>(Uri destinationAddress, DateTime scheduledTime, object values,
                                                                        CancellationToken cancellationToken)
        {
            if (destinationAddress == null)
            {
                throw new ArgumentNullException(nameof(destinationAddress));
            }
            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }

            var message = TypeMetadataCache <T> .InitializeFromObject(values);

            var pipeProxy = new ServiceBusScheduleMessagePipe <T>(scheduledTime);

            return(ScheduleSend(destinationAddress, scheduledTime, message, pipeProxy, cancellationToken));
        }
Exemplo n.º 3
0
        public async Task <ScheduledMessage <T> > ScheduleSend <T>(Uri destinationAddress, DateTime scheduledTime, Task <T> message, IPipe <SendContext <T> > pipe,
                                                                   CancellationToken cancellationToken)
            where T : class
        {
            var scheduleMessagePipe = new ServiceBusScheduleMessagePipe <T>(scheduledTime, pipe);

            var payload = await message.ConfigureAwait(false);

            var tokenId = ScheduleTokenIdCache <T> .GetTokenId(payload);

            scheduleMessagePipe.ScheduledMessageId = tokenId;

            var endpoint = await _sendEndpointProvider.GetSendEndpoint(destinationAddress).ConfigureAwait(false);

            await endpoint.Send(payload, pipe, cancellationToken).ConfigureAwait(false);

            return(new ScheduledMessageHandle <T>(scheduleMessagePipe.ScheduledMessageId ?? NewId.NextGuid(), scheduledTime, destinationAddress, payload));
        }
        async Task <ScheduledMessage <T> > ScheduleSend <T>(Uri destinationAddress, DateTime scheduledTime, T message, ServiceBusScheduleMessagePipe <T> pipe,
                                                            CancellationToken cancellationToken)
            where T : class
        {
            var endpoint = await _sendEndpointProvider.GetSendEndpoint(destinationAddress).ConfigureAwait(false);

            await endpoint.Send(message, pipe, cancellationToken).ConfigureAwait(false);

            return(new ScheduledMessageHandle <T>(pipe.ScheduledMessageId ?? NewId.NextGuid(), scheduledTime, destinationAddress, message));
        }