Class DefaultMessageProcessor
Provides the default implementation of the IMessageProcessor application service contract.
Inherited Members
Namespace: Kephas.Messaging
Assembly: Kephas.Messaging.dll
Syntax
[OverridePriority(Priority.Low)]
public class DefaultMessageProcessor : Loggable, ILoggable, IMessageProcessorConstructors
| Improve this Doc View SourceDefaultMessageProcessor(IContextFactory, IMessageHandlerRegistry, IMessageMatchService, IList<IExportFactory<IMessagingBehavior, MessagingBehaviorMetadata>>)
Initializes a new instance of the DefaultMessageProcessor class.
Declaration
public DefaultMessageProcessor(IContextFactory contextFactory, IMessageHandlerRegistry handlerRegistry, IMessageMatchService messageMatchService, IList<IExportFactory<IMessagingBehavior, MessagingBehaviorMetadata>> behaviorFactories)Parameters
| Type | Name | Description | 
|---|---|---|
| IContextFactory | contextFactory | The context factory. | 
| IMessageHandlerRegistry | handlerRegistry | The handler registry. | 
| IMessageMatchService | messageMatchService | The message match service. | 
| System.Collections.Generic.IList<IExportFactory<IMessagingBehavior, MessagingBehaviorMetadata>> | behaviorFactories | The behavior factories. | 
Properties
| Improve this Doc View SourceContextFactory
Gets the context factory.
Declaration
public IContextFactory ContextFactory { get; }Property Value
| Type | Description | 
|---|---|
| IContextFactory | The context factory. | 
Methods
| Improve this Doc View SourceApplyAfterProcessBehaviorsAsync(IEnumerable<IMessagingBehavior>, IMessagingContext, CancellationToken)
Applies the behaviors invoking the AfterProcessAsync(IMessagingContext, CancellationToken) asynchronously.
Declaration
protected virtual Task ApplyAfterProcessBehaviorsAsync(IEnumerable<IMessagingBehavior> reversedBehaviors, IMessagingContext context, CancellationToken token)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerable<IMessagingBehavior> | reversedBehaviors | The reversed behaviors. | 
| IMessagingContext | context | Context for the message processing. | 
| System.Threading.CancellationToken | token | The cancellation token. | 
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | An asynchronous result. | 
ApplyBeforeProcessBehaviorsAsync(IEnumerable<IMessagingBehavior>, IMessagingContext, CancellationToken)
Applies the behaviors invoking the BeforeProcessAsync(IMessagingContext, CancellationToken) asynchronously.
Declaration
protected virtual Task ApplyBeforeProcessBehaviorsAsync(IEnumerable<IMessagingBehavior> behaviors, IMessagingContext context, CancellationToken token)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerable<IMessagingBehavior> | behaviors | The reversed behaviors. | 
| IMessagingContext | context | Context for the message processing. | 
| System.Threading.CancellationToken | token | The cancellation token. | 
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task | An asynchronous result. | 
CreateProcessingContext(IMessage, IMessagingContext)
Creates the processing context.
Declaration
protected virtual IMessagingContext CreateProcessingContext(IMessage message, IMessagingContext parentContext)Parameters
| Type | Name | Description | 
|---|---|---|
| IMessage | message | The message. | 
| IMessagingContext | parentContext | The parent context. | 
Returns
| Type | Description | 
|---|---|
| IMessagingContext | The processing context. | 
GetOrderedBehaviors(IMessage)
Gets the ordered behaviors (direct and reversed) to be applied.
Declaration
protected virtual (IEnumerable<IMessagingBehavior> behaviors, IEnumerable<IMessagingBehavior> reversedBehaviors)GetOrderedBehaviors(IMessage message)Parameters
| Type | Name | Description | 
|---|---|---|
| IMessage | message | The message. | 
Returns
| Type | Description | 
|---|---|
| System.ValueTuple<System.Collections.Generic.IEnumerable<IMessagingBehavior>, System.Collections.Generic.IEnumerable<IMessagingBehavior>> | An ordered list of behaviors which can be applied to the provided message, with their reversed counterpart. | 
ProcessAsync(IMessage, IMessagingContext, CancellationToken)
Processes the specified message asynchronously.
Declaration
public Task<IMessage> ProcessAsync(IMessage message, IMessagingContext context = null, CancellationToken token = default(CancellationToken))Parameters
| Type | Name | Description | 
|---|---|---|
| IMessage | message | The message. | 
| IMessagingContext | context | Context for the message processing. | 
| System.Threading.CancellationToken | token | The cancellation token. | 
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task<IMessage> | The response promise. |