Class DefaultMessageBroker
Base implementation of a IMessageBroker.
Inherited Members
Namespace: Kephas.Messaging.Distributed
Assembly: Kephas.Messaging.dll
Syntax
[OverridePriority(Priority.Low)]
public class DefaultMessageBroker : Loggable, ILoggable, IMessageBroker, IAsyncInitializable, IAsyncFinalizable
Constructors
| Improve this Doc View SourceDefaultMessageBroker(ICollection<IExportFactory<IMessageRouter, MessageRouterMetadata>>, IExportFactory<IBrokeredMessageBuilder>)
Initializes a new instance of the DefaultMessageBroker class.
Declaration
public DefaultMessageBroker(ICollection<IExportFactory<IMessageRouter, MessageRouterMetadata>> routerFactories, IExportFactory<IBrokeredMessageBuilder> builderFactory)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.ICollection<IExportFactory<IMessageRouter, MessageRouterMetadata>> | routerFactories | The router factories. |
IExportFactory<IBrokeredMessageBuilder> | builderFactory | The builder factory. |
Methods
| Improve this Doc View SourceCreateBrokeredMessageBuilder(IContext)
Creates a brokered messsage builder.
Declaration
protected virtual IBrokeredMessageBuilder CreateBrokeredMessageBuilder(IContext context)
Parameters
Type | Name | Description |
---|---|---|
IContext | context | The publishing context. |
Returns
Type | Description |
---|---|
IBrokeredMessageBuilder | The new brokered messsage builder. |
DispatchAsync(IBrokeredMessage, IContext, CancellationToken)
Dispatches the brokered message asynchronously.
Declaration
public virtual Task<IMessage> DispatchAsync(IBrokeredMessage brokeredMessage, IContext context, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IBrokeredMessage | brokeredMessage | The brokered message. |
IContext | context | Optional. The dispatching context. |
System.Threading.CancellationToken | cancellationToken | Optional. The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<IMessage> | The asynchronous result that yields an IMessage. |
FinalizeAsync(IContext, CancellationToken)
Finalizes the service.
Declaration
public virtual Task FinalizeAsync(IContext context = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IContext | context | Optional. An optional context for finalization. |
System.Threading.CancellationToken | cancellationToken | Optional. The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | An asynchronous result. |
InitializeAsync(IContext, CancellationToken)
Initializes the service asynchronously.
Declaration
public virtual Task InitializeAsync(IContext context = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IContext | context | Optional. An optional context for initialization. |
System.Threading.CancellationToken | cancellationToken | Optional. The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | An awaitable task. |
ReceiveReply(IBrokeredMessage, IContext)
Notification method for receiving a reply.
Declaration
protected virtual void ReceiveReply(IBrokeredMessage replyMessage, IContext context = null)
Parameters
Type | Name | Description |
---|---|---|
IBrokeredMessage | replyMessage | Message describing the reply. |
IContext | context | Optional. The reply context. |
RouterDispatchAsync(IBrokeredMessage, IContext, CancellationToken)
Sends the brokered message asynchronously over the physical medium using registered routers.
Declaration
protected virtual Task RouterDispatchAsync(IBrokeredMessage brokeredMessage, IContext context, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IBrokeredMessage | brokeredMessage | The brokered message. |
IContext | context | The send context. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | The asynchronous result. |