Ejemplo n.º 1
0
        Task <ScheduledMessage <T> > ScheduleSend <T>(Uri destinationAddress, DateTime scheduledTime, T message, CancellationToken cancellationToken)
            where T : class
        {
            var pipe = new ScheduleMessageContextPipe <T>();

            return(ScheduleSend(destinationAddress, scheduledTime, message, pipe, cancellationToken));
        }
Ejemplo n.º 2
0
        Task <ScheduledMessage <T> > IMessageScheduler.ScheduleSend <T>(Uri destinationAddress, DateTime scheduledTime, T message, IPipe <SendContext> pipe, CancellationToken cancellationToken)
        {
            if (destinationAddress == null)
            {
                throw new ArgumentNullException(nameof(destinationAddress));
            }
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            if (pipe == null)
            {
                throw new ArgumentNullException(nameof(pipe));
            }

            var pipeProxy = new ScheduleMessageContextPipe <T>(pipe);

            return(ScheduleSend(destinationAddress, scheduledTime, message, pipeProxy, cancellationToken));
        }
Ejemplo n.º 3
0
        async Task <ScheduledMessage <T> > IScheduleMessageProvider.ScheduleSend <T>(Uri destinationAddress, DateTime scheduledTime, Task <T> message,
                                                                                     IPipe <SendContext <T> > pipe, CancellationToken cancellationToken)
        {
            var scheduleMessagePipe = new ScheduleMessageContextPipe <T>(pipe);

            var payload = await message.ConfigureAwait(false);

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

            scheduleMessagePipe.ScheduledMessageId = tokenId;

            ScheduleMessage <T> command = new ScheduleMessageCommand <T>(scheduledTime, destinationAddress, payload, tokenId);

            await ScheduleSend(command, scheduleMessagePipe, cancellationToken).ConfigureAwait(false);

            return(new ScheduledMessageHandle <T>(scheduleMessagePipe.ScheduledMessageId ?? command.CorrelationId, command.ScheduledTime,
                                                  command.Destination,
                                                  command.Payload));
        }
Ejemplo n.º 4
0
        Task <ScheduledMessage <T> > IMessageScheduler.ScheduleSend <T>(Uri destinationAddress, DateTime scheduledTime, object values, IPipe <SendContext> pipe, CancellationToken cancellationToken)
        {
            if (destinationAddress == null)
            {
                throw new ArgumentNullException(nameof(destinationAddress));
            }
            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }
            if (pipe == null)
            {
                throw new ArgumentNullException(nameof(pipe));
            }

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

            var pipeProxy = new ScheduleMessageContextPipe <T>(pipe);

            return(ScheduleSend(destinationAddress, scheduledTime, message, pipeProxy, cancellationToken));
        }
Ejemplo n.º 5
0
        async Task <ScheduledMessage <T> > ScheduleSend <T>(Uri destinationAddress, DateTime scheduledTime, T message, ScheduleMessageContextPipe <T> pipe,
                                                            CancellationToken cancellationToken)
            where T : class
        {
            var tokenId = ScheduleTokenIdCache <T> .GetTokenId(message);

            pipe.ScheduledMessageId = tokenId;

            ScheduleMessage <T> command = new ScheduleMessageCommand <T>(scheduledTime, destinationAddress, message, tokenId);

            var endpoint = await _schedulerEndpoint().ConfigureAwait(false);

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

            return(new ScheduledMessageHandle <T>(pipe.ScheduledMessageId ?? command.CorrelationId, command.ScheduledTime, command.Destination, command.Payload));
        }