示例#1
0
        /// <summary>
        /// Send a message
        /// </summary>
        /// <typeparam name="T">The message type</typeparam>
        /// <param name="context">The consume context</param>
        /// <param name="scheduledTime">The time at which the message should be delivered to the queue</param>
        /// <param name="message">The message</param>
        /// <param name="pipe"></param>
        /// <param name="cancellationToken"></param>
        /// <returns>The task which is completed once the Send is acknowledged by the broker</returns>
        public static Task <ScheduledMessage <T> > SchedulePublish <T>(this ConsumeContext context, DateTime scheduledTime, T message, IPipe <SendContext> pipe,
                                                                       CancellationToken cancellationToken = default)
            where T : class
        {
            var pipeProxy = new ServiceBusScheduleMessagePipe <T>(scheduledTime, pipe);

            return(Schedule(context, scheduledTime, message, pipeProxy, cancellationToken));
        }
示例#2
0
        static async Task <ScheduledMessage> Schedule(ConsumeContext context, DateTime scheduledTime, object message, Type messageType,
                                                      ServiceBusScheduleMessagePipe pipe, CancellationToken cancellationToken)
        {
            await context.Publish(message, pipe, cancellationToken).ConfigureAwait(false);

            var destinationAddress = GetDestinationAddress(context, messageType);

            return(new ScheduledMessageHandle(pipe.ScheduledMessageId ?? NewId.NextGuid(), scheduledTime, destinationAddress));
        }
示例#3
0
        /// <summary>
        ///     Sends an interface message, initializing the properties of the interface using the anonymous
        ///     object specified
        /// </summary>
        /// <typeparam name="T">The interface type to send</typeparam>
        /// <param name="context">The consume context</param>
        /// <param name="scheduledTime">The time at which the message should be delivered to the queue</param>
        /// <param name="values">The property values to initialize on the interface</param>
        /// <param name="pipe"></param>
        /// <param name="cancellationToken"></param>
        /// <returns>The task which is completed once the Send is acknowledged by the broker</returns>
        public static Task <ScheduledMessage <T> > SchedulePublish <T>(this ConsumeContext context, DateTime scheduledTime, object values, IPipe <SendContext> pipe,
                                                                       CancellationToken cancellationToken = default)
            where T : class
        {
            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }

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

            return(Schedule(context, scheduledTime, values, pipeProxy, cancellationToken));
        }
示例#4
0
        /// <summary>
        ///     Sends an object as a message, using the type of the message instance.
        /// </summary>
        /// <param name="context">The consume context</param>
        /// <param name="scheduledTime">The time at which the message should be delivered to the queue</param>
        /// <param name="message">The message object</param>
        /// <param name="cancellationToken"></param>
        /// <returns>The task which is completed once the Send is acknowledged by the broker</returns>
        public static Task <ScheduledMessage> SchedulePublish(this ConsumeContext context, DateTime scheduledTime, object message,
                                                              CancellationToken cancellationToken = default)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            var messageType = message.GetType();

            var pipeProxy = new ServiceBusScheduleMessagePipe(scheduledTime);

            return(Schedule(context, scheduledTime, message, messageType, pipeProxy, cancellationToken));
        }
示例#5
0
        /// <summary>
        ///     Sends an interface message, initializing the properties of the interface using the anonymous
        ///     object specified
        /// </summary>
        /// <typeparam name="T">The interface type to send</typeparam>
        /// <param name="context">The consume context</param>
        /// <param name="scheduledTime">The time at which the message should be delivered to the queue</param>
        /// <param name="values">The property values to initialize on the interface</param>
        /// <param name="cancellationToken"></param>
        /// <returns>The task which is completed once the Send is acknowledged by the broker</returns>
        public static Task <ScheduledMessage <T> > SchedulePublish <T>(this ConsumeContext context, DateTime scheduledTime, object values,
                                                                       CancellationToken cancellationToken = default(CancellationToken))
            where T : class
        {
            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }

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

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

            return(Schedule(context, scheduledTime, message, pipeProxy, cancellationToken));
        }
示例#6
0
        static async Task <ScheduledMessage <T> > Schedule <T>(ConsumeContext context, DateTime scheduledTime, T message, ServiceBusScheduleMessagePipe <T> pipe,
                                                               CancellationToken cancellationToken)
            where T : class
        {
            await context.Publish(message, pipe, cancellationToken).ConfigureAwait(false);

            var destinationAddress = GetDestinationAddress(context, message);

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