Show / Hide Table of Contents

    Class CommandPublisherExtensions

    Adds the ExecuteCommand(IPublisher, ICommand, bool) and ExecuteCommandAsync(IPublisher, ICommand, CancellationToken) methods to the IPublisher interface.

    Inheritance
    object
    CommandPublisherExtensions
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: Silverback.Messaging.Publishing
    Assembly: Silverback.Core.Model.dll
    Syntax
    public static class CommandPublisherExtensions

    Methods

    ExecuteCommand(IPublisher, ICommand, bool)

    Executes the specified command forwarding it to its subscribers via the message bus and the method will not complete until all subscribers have processed it (unless using Silverback.Integration to produce and consume the message through a message broker).

    Declaration
    public static void ExecuteCommand(this IPublisher publisher, ICommand commandMessage, bool throwIfUnhandled = true)
    Parameters
    Type Name Description
    IPublisher publisher

    The IPublisher.

    ICommand commandMessage

    The command to be executed.

    bool throwIfUnhandled

    A boolean value indicating whether an exception must be thrown if no subscriber is handling the message.

    ExecuteCommandAsync(IPublisher, ICommand, bool, CancellationToken)

    Executes the specified command forwarding it to its subscribers via the message bus and the method will not complete until all subscribers have processed it (unless using Silverback.Integration to produce and consume the message through a message broker).

    Declaration
    public static Task ExecuteCommandAsync(this IPublisher publisher, ICommand commandMessage, bool throwIfUnhandled, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    IPublisher publisher

    The IPublisher.

    ICommand commandMessage

    The command to be executed.

    bool throwIfUnhandled

    A boolean value indicating whether an exception must be thrown if no subscriber is handling the message.

    CancellationToken cancellationToken

    The CancellationToken that can be used to cancel the operation.

    Returns
    Type Description
    Task

    A Task representing the asynchronous operation.

    ExecuteCommandAsync(IPublisher, ICommand, CancellationToken)

    Executes the specified command forwarding it to its subscribers via the message bus and the method will not complete until all subscribers have processed it (unless using Silverback.Integration to produce and consume the message through a message broker).

    Declaration
    public static Task ExecuteCommandAsync(this IPublisher publisher, ICommand commandMessage, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    IPublisher publisher

    The IPublisher.

    ICommand commandMessage

    The command to be executed.

    CancellationToken cancellationToken

    The CancellationToken that can be used to cancel the operation.

    Returns
    Type Description
    Task

    A Task representing the asynchronous operation.

    ExecuteCommandAsync<TResult>(IPublisher, ICommand<TResult>, bool, CancellationToken)

    Executes the specified command forwarding it to its subscribers via the message bus and the method will not complete until all subscribers have processed it (unless using Silverback.Integration to produce and consume the message through a message broker).

    Declaration
    public static Task<TResult> ExecuteCommandAsync<TResult>(this IPublisher publisher, ICommand<TResult> commandMessage, bool throwIfUnhandled, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    IPublisher publisher

    The IPublisher.

    ICommand<TResult> commandMessage

    The command to be executed.

    bool throwIfUnhandled

    A boolean value indicating whether an exception must be thrown if no subscriber is handling the message.

    CancellationToken cancellationToken

    The CancellationToken that can be used to cancel the operation.

    Returns
    Type Description
    Task<TResult>

    A Task<TResult> representing the asynchronous operation. The Task result contains the command result.

    Type Parameters
    Name Description
    TResult

    The type of the result that is expected to be returned by the subscribers.

    ExecuteCommandAsync<TResult>(IPublisher, ICommand<TResult>, CancellationToken)

    Executes the specified command forwarding it to its subscribers via the message bus and the method will not complete until all subscribers have processed it (unless using Silverback.Integration to produce and consume the message through a message broker).

    Declaration
    public static Task<TResult> ExecuteCommandAsync<TResult>(this IPublisher publisher, ICommand<TResult> commandMessage, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    IPublisher publisher

    The IPublisher.

    ICommand<TResult> commandMessage

    The command to be executed.

    CancellationToken cancellationToken

    The CancellationToken that can be used to cancel the operation.

    Returns
    Type Description
    Task<TResult>

    A Task<TResult> representing the asynchronous operation. The Task result contains the command result.

    Type Parameters
    Name Description
    TResult

    The type of the result that is expected to be returned by the subscribers.

    ExecuteCommand<TResult>(IPublisher, ICommand<TResult>, bool)

    Executes the specified command forwarding it to its subscribers via the message bus and the method will not complete until all subscribers have processed it (unless using Silverback.Integration to produce and consume the message through a message broker).

    Declaration
    public static TResult ExecuteCommand<TResult>(this IPublisher publisher, ICommand<TResult> commandMessage, bool throwIfUnhandled = true)
    Parameters
    Type Name Description
    IPublisher publisher

    The IPublisher.

    ICommand<TResult> commandMessage

    The command to be executed.

    bool throwIfUnhandled

    A boolean value indicating whether an exception must be thrown if no subscriber is handling the message.

    Returns
    Type Description
    TResult

    The command result.

    Type Parameters
    Name Description
    TResult

    The type of the result that is expected to be returned by the subscribers.

    GitHub E-Mail
    ↑ Back to top © 2026 Sergio Aquilini