Class CommandPublisherExtensions
- Namespace
- Silverback.Messaging.Publishing
- Assembly
- Silverback.Core.Model.dll
Adds the ExecuteCommand(IPublisher, ICommand, bool) and ExecuteCommandAsync(IPublisher, ICommand, CancellationToken) methods to the IPublisher interface.
public static class CommandPublisherExtensions
- Inheritance
-
CommandPublisherExtensions
- Inherited Members
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).
public static void ExecuteCommand(this IPublisher publisher, ICommand commandMessage, bool throwIfUnhandled = true)
Parameters
publisherIPublisherThe IPublisher.
commandMessageICommandThe command to be executed.
throwIfUnhandledboolA 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).
public static Task ExecuteCommandAsync(this IPublisher publisher, ICommand commandMessage, bool throwIfUnhandled, CancellationToken cancellationToken = default)
Parameters
publisherIPublisherThe IPublisher.
commandMessageICommandThe command to be executed.
throwIfUnhandledboolA boolean value indicating whether an exception must be thrown if no subscriber is handling the message.
cancellationTokenCancellationTokenThe CancellationToken that can be used to cancel the operation.
Returns
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).
public static Task ExecuteCommandAsync(this IPublisher publisher, ICommand commandMessage, CancellationToken cancellationToken = default)
Parameters
publisherIPublisherThe IPublisher.
commandMessageICommandThe command to be executed.
cancellationTokenCancellationTokenThe CancellationToken that can be used to cancel the operation.
Returns
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).
public static Task<TResult> ExecuteCommandAsync<TResult>(this IPublisher publisher, ICommand<TResult> commandMessage, bool throwIfUnhandled, CancellationToken cancellationToken = default)
Parameters
publisherIPublisherThe IPublisher.
commandMessageICommand<TResult>The command to be executed.
throwIfUnhandledboolA boolean value indicating whether an exception must be thrown if no subscriber is handling the message.
cancellationTokenCancellationTokenThe CancellationToken that can be used to cancel the operation.
Returns
- Task<TResult>
A Task<TResult> representing the asynchronous operation. The Task result contains the command result.
Type Parameters
TResultThe 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).
public static Task<TResult> ExecuteCommandAsync<TResult>(this IPublisher publisher, ICommand<TResult> commandMessage, CancellationToken cancellationToken = default)
Parameters
publisherIPublisherThe IPublisher.
commandMessageICommand<TResult>The command to be executed.
cancellationTokenCancellationTokenThe CancellationToken that can be used to cancel the operation.
Returns
- Task<TResult>
A Task<TResult> representing the asynchronous operation. The Task result contains the command result.
Type Parameters
TResultThe 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).
public static TResult ExecuteCommand<TResult>(this IPublisher publisher, ICommand<TResult> commandMessage, bool throwIfUnhandled = true)
Parameters
publisherIPublisherThe IPublisher.
commandMessageICommand<TResult>The command to be executed.
throwIfUnhandledboolA boolean value indicating whether an exception must be thrown if no subscriber is handling the message.
Returns
- TResult
The command result.
Type Parameters
TResultThe type of the result that is expected to be returned by the subscribers.