Class EventPublisherExtensions
Adds the PublishEvent(IPublisher, IEvent, bool) and PublishEventAsync(IPublisher, IEvent, CancellationToken) methods to the IPublisher interface.
Inherited Members
Namespace: Silverback.Messaging.Publishing
Assembly: Silverback.Core.Model.dll
Syntax
public static class EventPublisherExtensions
Methods
PublishEvent(IPublisher, IEvent, bool)
Publishes the specified event 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 PublishEvent(this IPublisher publisher, IEvent eventMessage, bool throwIfUnhandled = false)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublisher | publisher | The IPublisher. |
| IEvent | eventMessage | The event to be published. |
| bool | throwIfUnhandled | A boolean value indicating whether an exception must be thrown if no subscriber is handling the message. |
PublishEventAsync(IPublisher, IEvent, bool, CancellationToken)
Publishes the specified event to its subscribers via the message bus and the Task 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 PublishEventAsync(this IPublisher publisher, IEvent eventMessage, bool throwIfUnhandled, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublisher | publisher | The IPublisher. |
| IEvent | eventMessage | The event to be published. |
| 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. |
PublishEventAsync(IPublisher, IEvent, CancellationToken)
Publishes the specified event to its subscribers via the message bus and the Task 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 PublishEventAsync(this IPublisher publisher, IEvent eventMessage, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublisher | publisher | The IPublisher. |
| IEvent | eventMessage | The event to be published. |
| CancellationToken | cancellationToken | The CancellationToken that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task | A Task representing the asynchronous operation. |