Ejemplo n.º 1
0
        /// <summary>
        /// Request for a timeout to occur within the given <see cref="TimeSpan" />.
        /// </summary>
        /// <param name="context">The context which is used to send the timeout.</param>
        /// <param name="within">Given <see cref="TimeSpan" /> to delay timeout message by.</param>
        /// <param name="timeoutMessage">The message to send after <paramref name="within" /> expires.</param>
        protected Task RequestTimeout <TTimeoutMessageType>(IMessageHandlerContext context, TimeSpan within, TTimeoutMessageType timeoutMessage)
        {
            VerifySagaCanHandleTimeout(timeoutMessage);

            var sendOptions = new SendOptions();

            sendOptions.DelayDeliveryWith(within);
            sendOptions.RouteToThisEndpoint();

            SetTimeoutHeaders(sendOptions);

            return(context.Send(timeoutMessage, sendOptions));
        }
Ejemplo n.º 2
0
        static Task DeferTask(TaskDefinition taskDefinition, IBusContext bus)
        {
            var options = new SendOptions();

            options.DelayDeliveryWith(taskDefinition.Every);
            options.RouteToLocalEndpointInstance();

            return(bus.Send(new ScheduledTask
            {
                TaskId = taskDefinition.Id,
                Name = taskDefinition.Name,
                Every = taskDefinition.Every
            }, options));
        }
Ejemplo n.º 3
0
        static Task DeferTask(TaskDefinition taskDefinition, IPipelineContext context)
        {
            var options = new SendOptions();

            options.DelayDeliveryWith(taskDefinition.Every);
            options.RouteToThisEndpoint();

            return(context.Send(new ScheduledTask
            {
                TaskId = taskDefinition.Id,
                Name = taskDefinition.Name,
                Every = taskDefinition.Every
            }, options));
        }
Ejemplo n.º 4
0
        static Task Schedule(IMessageSession session, TaskDefinition taskDefinition)
        {
            logger.DebugFormat("Task '{0}' (with id {1}) scheduled with timeSpan {2}", taskDefinition.Name, taskDefinition.Id, taskDefinition.Every);

            var options = new SendOptions();

            options.DelayDeliveryWith(taskDefinition.Every);
            options.RouteToThisEndpoint();
            options.Context.GetOrCreate <ScheduleBehavior.State>().TaskDefinition = taskDefinition;

            return(session.Send(new ScheduledTask
            {
                TaskId = taskDefinition.Id,
                Name = taskDefinition.Name,
                Every = taskDefinition.Every
            }, options));
        }