/// <summary>
        /// Instantiates a message of <typeparamref name="T" /> and sends it.
        /// </summary>
        /// <typeparam name="T">The type of message, usually an interface.</typeparam>
        /// <param name="context">The instance of <see cref="IPipelineContext" /> to use for the action.</param>
        /// <param name="messageConstructor">An action which initializes properties of the message.</param>
        /// <remarks>
        /// The message will be sent to the destination configured for <typeparamref name="T" />.
        /// </remarks>
        public static Task Send <T>(this IPipelineContext context, Action <T> messageConstructor)
        {
            Guard.AgainstNull(nameof(context), context);
            Guard.AgainstNull(nameof(messageConstructor), messageConstructor);

            return(context.Send(messageConstructor, new SendOptions()));
        }
        /// <summary>
        /// Sends the provided message.
        /// </summary>
        /// <param name="context">The instance of <see cref="IPipelineContext" /> to use for the action.</param>
        /// <param name="message">The message to send.</param>
        public static Task Send(this IPipelineContext context, object message)
        {
            Guard.AgainstNull(nameof(context), context);
            Guard.AgainstNull(nameof(message), message);

            return(context.Send(message, new SendOptions()));
        }
Esempio n. 3
0
 async Task RequestImmediateDispatch(IPipelineContext context)
 {
     #region RequestImmediateDispatch
     SendOptions options = new SendOptions();
     options.RequireImmediateDispatch();
     await context.Send(new MyMessage(), options);
     #endregion
 }
Esempio n. 4
0
        async Task RequestImmediateDispatch(IPipelineContext context)
        {
            #region RequestImmediateDispatch
            SendOptions options = new SendOptions();
            options.RequireImmediateDispatch();
            await context.Send(new MyMessage(), options);

            #endregion
        }
        async Task DisablePerMessage(IPipelineContext context)
        {
            #region DisableBestPracticeEnforcementPerMessage
            SendOptions options = new SendOptions();

            options.DoNotEnforceBestPractices();

            await context.Send(new MyEvent(), options);
            #endregion
        }
Esempio n. 6
0
        async Task Correlation(IPipelineContext context)
        {
            #region custom-correlationid
            SendOptions options = new SendOptions();

            options.SetCorrelationId("My custom correlation id");

            await context.Send(new MyRequest(), options);

            #endregion
        }
        /// <summary>
        /// Sends the message back to the current endpoint.
        /// </summary>
        /// <param name="context">Object being extended.</param>
        /// <param name="message">The message to send.</param>
        public static Task SendLocal(this IPipelineContext context, object message)
        {
            Guard.AgainstNull(nameof(context), context);
            Guard.AgainstNull(nameof(message), message);

            var options = new SendOptions();

            options.RouteToThisEndpoint();

            return(context.Send(message, options));
        }
        async Task DisablePerMessage(IPipelineContext context)
        {
            #region DisableBestPracticeEnforcementPerMessage
            SendOptions options = new SendOptions();

            options.DoNotEnforceBestPractices();

            await context.Send(new MyEvent(), options);

            #endregion
        }
        /// <summary>
        /// Instantiates a message of type T and sends it back to the current endpoint.
        /// </summary>
        /// <typeparam name="T">The type of message, usually an interface.</typeparam>
        /// <param name="context">Object being extended.</param>
        /// <param name="messageConstructor">An action which initializes properties of the message.</param>
        public static Task SendLocal <T>(this IPipelineContext context, Action <T> messageConstructor)
        {
            Guard.AgainstNull(nameof(context), context);
            Guard.AgainstNull(nameof(messageConstructor), messageConstructor);

            var options = new SendOptions();

            options.RouteToThisEndpoint();

            return(context.Send(messageConstructor, options));
        }
Esempio n. 10
0
        async Task Correlation(IPipelineContext context)
        {
            #region custom-correlationid
            SendOptions options = new SendOptions();

            options.SetCorrelationId("My custom correlation id");

            await context.Send(new MyRequest(),options);

            #endregion
        }
Esempio n. 11
0
        async Task RequestImmediateDispatch(IPipelineContext context)
        {
            #region RequestImmediateDispatch
            var options = new SendOptions();
            options.RequireImmediateDispatch();
            var message = new MyMessage();
            await context.Send(message, options)
            .ConfigureAwait(false);

            #endregion
        }
        /// <summary>
        /// Instantiates a message of type T and sends it to the given destination.
        /// </summary>
        /// <typeparam name="T">The type of message, usually an interface.</typeparam>
        /// <param name="context">The instance of <see cref="IPipelineContext" /> to use for the action.</param>
        /// <param name="destination">The destination to which the message will be sent.</param>
        /// <param name="messageConstructor">An action which initializes properties of the message.</param>
        public static Task Send <T>(this IPipelineContext context, string destination, Action <T> messageConstructor)
        {
            Guard.AgainstNull(nameof(context), context);
            Guard.AgainstNullAndEmpty(nameof(destination), destination);
            Guard.AgainstNull(nameof(messageConstructor), messageConstructor);

            var options = new SendOptions();

            options.SetDestination(destination);

            return(context.Send(messageConstructor, options));
        }
        /// <summary>
        /// Sends the message.
        /// </summary>
        /// <param name="context">The instance of <see cref="IPipelineContext" /> to use for the action.</param>
        /// <param name="destination">The address of the destination to which the message will be sent.</param>
        /// <param name="message">The message to send.</param>
        public static Task Send(this IPipelineContext context, string destination, object message)
        {
            Guard.AgainstNull(nameof(context), context);
            Guard.AgainstNullAndEmpty(nameof(destination), destination);
            Guard.AgainstNull(nameof(message), message);

            var options = new SendOptions();

            options.SetDestination(destination);

            return context.Send(message, options);
        }
Esempio n. 14
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);
        }
Esempio n. 15
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));
        }
        public static Task Route(this IPipelineContext bus, object message, Guid routingSlipId, params string[] destinations)
        {
            var options = BuildSendOptions(routingSlipId, destinations);

            return(bus.Send(message, options));
        }
Esempio n. 17
0
        public Task Send(object message, SendOptions options)
        {
            ThrowIfDisposed();

            return(pipelineContext.Send(message, options));
        }