/// <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> /// <param name="sendPipe"></param> /// <returns>A handled to the scheduled message</returns> public static async Task <ScheduledMessage <T> > ScheduleSend <T>(this ISendEndpoint endpoint, Uri destinationAddress, DateTime scheduledTime, T message, IPipe <SendContext <ScheduleMessage <T> > > sendPipe) where T : class { var command = new ScheduleMessageCommand <T>(scheduledTime, destinationAddress, message); await endpoint.Send(command, sendPipe).ConfigureAwait(false); 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="publishEndpoint">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 async Task <ScheduledMessage <T> > ScheduleMessage <T>(this IPublishEndpoint publishEndpoint, Uri destinationAddress, DateTime scheduledTime, T message, IPipe <PublishContext <ScheduleMessage <T> > > contextCallback = null) where T : class { var command = new ScheduleMessageCommand <T>(scheduledTime, destinationAddress, message); await publishEndpoint.Publish(command, contextCallback ?? Pipe.Empty <PublishContext <ScheduleMessage <T> > >()).ConfigureAwait(false); return(new ScheduledMessageHandle <T>(command.CorrelationId, command.ScheduledTime, command.Destination, command.Payload)); }