예제 #1
0
        async Task <ScheduledMessage <T> > ScheduleSend <T>(Uri destinationAddress, DateTime scheduledTime, T message, CancellationToken cancellationToken)
            where T : class
        {
            ScheduleMessage <T> command = new ScheduleMessageCommand <T>(scheduledTime, destinationAddress, message);

            await _publishEndpoint.Publish(command, cancellationToken).ConfigureAwait(false);

            return(new ScheduledMessageHandle <T>(command.CorrelationId, command.ScheduledTime, command.Destination, command.Payload));
        }
        /// <summary>
        /// Sends a ScheduleMessage command to the endpoint, using the specified arguments
        /// </summary>
        /// <typeparam name="T">The scheduled message type</typeparam>
        /// <param name="endpoint">The endpoint of the message scheduling service</param>
        /// <param name="destinationAddress">The destination address where the schedule message should be sent</param>
        /// <param name="scheduledTime">The time when the message should be sent to the endpoint</param>
        /// <param name="message">The message to send</param>
        /// <returns>A handled to the scheduled message</returns>
        public static ScheduledMessage <T> ScheduleSend <T>(this IEndpoint endpoint, Uri destinationAddress, DateTime scheduledTime, T message)
            where T : class
        {
            var command = new ScheduleMessageCommand <T>(scheduledTime, destinationAddress, message);

            endpoint.Send <ScheduleMessage <T> >(command);

            return(new ScheduledMessageHandle <T>(command.CorrelationId, command.ScheduledTime, command.Destination,
                                                  command.Payload));
        }
        /// <summary>
        /// Schedules a message to be sent to the bus using a Publish, which should only be used when
        /// the quartz service is on a single shared queue or behind a distributor
        /// </summary>
        /// <typeparam name="T">The scheduled message type</typeparam>
        /// <param name="bus">The bus from which the scheduled message command should be published</param>
        /// <param name="destinationAddress">The destination address where the schedule message should be sent</param>
        /// <param name="scheduledTime">The time when the message should be sent to the endpoint</param>
        /// <param name="message">The message to send</param>
        /// <param name="contextCallback">Optional: A callback that gives the caller access to the publish context.</param>
        /// <returns>A handled to the scheduled message</returns>
        public static ScheduledMessage <T> ScheduleMessage <T>(this IServiceBus bus, Uri destinationAddress, DateTime scheduledTime, T message, Action <IPublishContext <ScheduleMessage <T> > > contextCallback = null)
            where T : class
        {
            var command = new ScheduleMessageCommand <T>(scheduledTime, destinationAddress, message);

            bus.Publish <ScheduleMessage <T> >(command, contextCallback ?? (c => {}));

            return(new ScheduledMessageHandle <T>(command.CorrelationId, command.ScheduledTime, command.Destination,
                                                  command.Payload));
        }
예제 #4
0
        async Task <ScheduledMessage <T> > ScheduleSend <T>(Uri destinationAddress, DateTime scheduledTime, T message, IPipe <SendContext <ScheduleMessage <T> > > pipe,
                                                            CancellationToken cancellationToken)
            where T : class
        {
            ScheduleMessage <T> command = new ScheduleMessageCommand <T>(scheduledTime, destinationAddress, message);

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

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

            return(new ScheduledMessageHandle <T>(command.CorrelationId, command.ScheduledTime, command.Destination, command.Payload));
        }
예제 #5
0
        async Task <ScheduledMessage <T> > ScheduleSend <T>(Uri destinationAddress, DateTime scheduledTime, T message, IPipe <SendContext <ScheduleMessage <T> > > pipe,
                                                            CancellationToken cancellationToken)
            where T : class
        {
            Guid tokenId = ScheduleTokenIdCache <T> .GetTokenId(message);

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

            await _publishEndpoint.Publish(command, pipe, cancellationToken).ConfigureAwait(false);

            return(new ScheduledMessageHandle <T>(command.CorrelationId, command.ScheduledTime, command.Destination, command.Payload));
        }
예제 #6
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));
        }
예제 #7
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));
        }