Ejemplo n.º 1
0
        /// <summary>
        ///     Sends an object as a message, using the type of the message instance.
        /// </summary>
        /// <param name="endpoint">The message scheduler endpoint</param>
        /// <param name="message">The message object</param>
        /// <param name="destinationAddress">The destination address where the schedule message should be sent</param>
        /// <param name="scheduledTime">The time at which the message should be delivered to the queue</param>
        /// <param name="cancellationToken"></param>
        /// <returns>The task which is completed once the Send is acknowledged by the broker</returns>
        public static Task <ScheduledMessage> ScheduleSend(this ISendEndpoint endpoint, Uri destinationAddress, DateTime scheduledTime, object message,
                                                           CancellationToken cancellationToken = default(CancellationToken))
        {
            IMessageScheduler scheduler = new EndpointMessageScheduler(endpoint);

            return(scheduler.ScheduleSend(destinationAddress, scheduledTime, message, cancellationToken));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Send a message
        /// </summary>
        /// <typeparam name="T">The message type</typeparam>
        /// <param name="endpoint">The message scheduler endpoint</param>
        /// <param name="message">The message</param>
        /// <param name="destinationAddress">The destination address where the schedule message should be sent</param>
        /// <param name="scheduledTime">The time at which the message should be delivered to the queue</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> > ScheduleSend <T>(this ISendEndpoint endpoint, Uri destinationAddress, DateTime scheduledTime, T message,
                                                                    IPipe <SendContext> pipe, CancellationToken cancellationToken = default(CancellationToken))
            where T : class
        {
            IMessageScheduler scheduler = new EndpointMessageScheduler(endpoint);

            return(scheduler.ScheduleSend(destinationAddress, scheduledTime, message, pipe, cancellationToken));
        }
Ejemplo n.º 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="endpoint">The message scheduler endpoint</param>
        /// <param name="values">The property values to initialize on the interface</param>
        /// <param name="destinationAddress">The destination address where the schedule message should be sent</param>
        /// <param name="scheduledTime">The time at which the message should be delivered to the queue</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> > ScheduleSend <T>(this ISendEndpoint endpoint, Uri destinationAddress, DateTime scheduledTime, object values,
                                                                    CancellationToken cancellationToken = default(CancellationToken))
            where T : class
        {
            IMessageScheduler scheduler = new EndpointMessageScheduler(endpoint);

            return(scheduler.ScheduleSend <T>(destinationAddress, scheduledTime, values, cancellationToken));
        }
Ejemplo n.º 4
0
        Task IFilter <ConsumeContext> .Send(ConsumeContext context, IPipe <ConsumeContext> next)
        {
            var scheduler = new EndpointMessageScheduler(context, _schedulerAddress);

            MessageSchedulerContext schedulerContext = new ConsumeMessageSchedulerContext(context, scheduler);

            context.GetOrAddPayload(() => schedulerContext);

            return(next.Send(context));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Cancel a scheduled message using the tokenId that was returned when the message was scheduled.
        /// </summary>
        /// <param name="endpoint">The endpoint of the scheduling service</param>
        /// <param name="tokenId">The tokenId of the scheduled message</param>
        public static Task CancelScheduledSend(this ISendEndpoint endpoint, Guid tokenId)
        {
            IMessageScheduler scheduler = new EndpointMessageScheduler(endpoint);

            return(scheduler.CancelScheduledSend(tokenId));
        }