Class QueryPublisherExtensions
Adds the ExecuteQuery<TResult>(IPublisher, IQuery<TResult>, bool) and ExecuteQueryAsync<TResult>(IPublisher, IQuery<TResult>, CancellationToken) methods to the IPublisher interface.
Inherited Members
Namespace: Silverback.Messaging.Publishing
Assembly: Silverback.Core.Model.dll
Syntax
public static class QueryPublisherExtensions
Methods
ExecuteQueryAsync<TResult>(IPublisher, IQuery<TResult>, bool, CancellationToken)
Executes the specified query 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 ValueTask<TResult> ExecuteQueryAsync<TResult>(this IPublisher publisher, IQuery<TResult> queryMessage, bool throwIfUnhandled, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublisher | publisher | The IPublisher. |
| IQuery<TResult> | queryMessage | The query 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 |
|---|---|
| ValueTask<TResult> | A ValueTask<TResult> representing the asynchronous operation. The ValueTask result contains the query result. |
Type Parameters
| Name | Description |
|---|---|
| TResult | The type of the result that is expected to be returned by the subscribers. |
ExecuteQueryAsync<TResult>(IPublisher, IQuery<TResult>, CancellationToken)
Executes the specified query 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 ValueTask<TResult> ExecuteQueryAsync<TResult>(this IPublisher publisher, IQuery<TResult> queryMessage, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublisher | publisher | The IPublisher. |
| IQuery<TResult> | queryMessage | The query to be executed. |
| CancellationToken | cancellationToken | The CancellationToken that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask<TResult> | A ValueTask<TResult> representing the asynchronous operation. The ValueTask result contains the query result. |
Type Parameters
| Name | Description |
|---|---|
| TResult | The type of the result that is expected to be returned by the subscribers. |
ExecuteQuery<TResult>(IPublisher, IQuery<TResult>, bool)
Executes the specified query 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 ExecuteQuery<TResult>(this IPublisher publisher, IQuery<TResult> queryMessage, bool throwIfUnhandled = true)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublisher | publisher | The IPublisher. |
| IQuery<TResult> | queryMessage | The query 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 query result. |
Type Parameters
| Name | Description |
|---|---|
| TResult | The type of the result that is expected to be returned by the subscribers. |