Show / Hide Table of Contents

Class MessageRouterBase

Base class for message routers.

Inheritance
System.Object
Loggable
MessageRouterBase
InProcessMessageRouter
Implements
ILoggable
IMessageRouter
System.IDisposable
Inherited Members
Loggable.Logger
Loggable.GetLogger()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Kephas.Messaging.Distributed.Routing
Assembly: Kephas.Messaging.dll
Syntax
public abstract class MessageRouterBase : Loggable, ILoggable, IMessageRouter, IDisposable

Constructors

| Improve this Doc View Source

MessageRouterBase(IMessageProcessor, IExportFactory<IBrokeredMessageBuilder>)

Initializes a new instance of the MessageRouterBase class.

Declaration
protected MessageRouterBase(IMessageProcessor messageProcessor, IExportFactory<IBrokeredMessageBuilder> messageBuilderFactory)
Parameters
Type Name Description
IMessageProcessor messageProcessor

The message processor.

IExportFactory<IBrokeredMessageBuilder> messageBuilderFactory

The message builder factory.

Properties

| Improve this Doc View Source

MessageProcessor

Gets the message processor.

Declaration
public IMessageProcessor MessageProcessor { get; }
Property Value
Type Description
IMessageProcessor

The message processor.

Methods

| Improve this Doc View Source

CreateBrokeredMessageBuilder(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.

| Improve this Doc View Source

DispatchAsync(IBrokeredMessage, IContext, CancellationToken)

Sends the brokered message asynchronously over the physical medium.

Declaration
public virtual Task<(RoutingInstruction action, IMessage reply)> DispatchAsync(IBrokeredMessage brokeredMessage, IContext context, CancellationToken cancellationToken)
Parameters
Type Name Description
IBrokeredMessage brokeredMessage

The brokered message.

IContext context

The routing context.

System.Threading.CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<System.ValueTuple<RoutingInstruction, IMessage>>

The asynchronous result yielding an action to take further and an optional reply.

Remarks

This method is invoked by the message broker when it identifies this router as handler for a brokered message. The router needs to send the message through the physical medium and, if necessary, prepare a response.

| Improve this Doc View Source

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Declaration
public void Dispose()
| Improve this Doc View Source

Dispose(Boolean)

Releases the unmanaged resources used by the MessageRouterBase and optionally releases the managed resources.

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
System.Boolean disposing

True to release both managed and unmanaged resources; false to release only unmanaged resources.

| Improve this Doc View Source

OnReplyReceived(ReplyReceivedEventArgs)

Raises the reply received event.

Declaration
protected virtual void OnReplyReceived(ReplyReceivedEventArgs eventArgs)
Parameters
Type Name Description
ReplyReceivedEventArgs eventArgs

Event information to send to registered event handlers.

| Improve this Doc View Source

ProcessAsync(IBrokeredMessage, IContext, CancellationToken)

Processes the brokered message locally, asynchronously.

Declaration
protected virtual Task<IMessage> ProcessAsync(IBrokeredMessage brokeredMessage, IContext context, CancellationToken cancellationToken)
Parameters
Type Name Description
IBrokeredMessage brokeredMessage

The brokered message.

IContext context

The routing context.

System.Threading.CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
System.Threading.Tasks.Task<IMessage>

An asynchronous result that yields the reply message.

| Improve this Doc View Source

RouteInputAsync(IBrokeredMessage, IContext, CancellationToken)

Routes the message received from the input queue asynchronously.

Declaration
protected virtual Task<(RoutingInstruction action, IMessage reply)> RouteInputAsync(IBrokeredMessage brokeredMessage, IContext context, CancellationToken cancellationToken)
Parameters
Type Name Description
IBrokeredMessage brokeredMessage

The brokered message.

IContext context

The routing context.

System.Threading.CancellationToken cancellationToken

A token that allows processing to be cancelled.

Returns
Type Description
System.Threading.Tasks.Task<System.ValueTuple<RoutingInstruction, IMessage>>

An asynchronous result.

Remarks

This method is called by the input queue when a message is received. For a reply, the router notifies the message broker, otherwise it calls the message processor to handle the message. Depending whether the message is one-way or not, a reply is routed through the output queue.

| Improve this Doc View Source

RouteOutputAsync(IBrokeredMessage, IContext, CancellationToken)

Routes the brokered message asynchronously, typically over the physical medium.

Declaration
protected abstract Task<(RoutingInstruction action, IMessage reply)> RouteOutputAsync(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<System.ValueTuple<RoutingInstruction, IMessage>>

The asynchronous result yielding an action to take further and an optional reply.

Remarks

The one-way handling is performed in the DispatchAsync(IBrokeredMessage, IContext, CancellationToken) method, here the message is purely routed through the transport medium.

Events

| Improve this Doc View Source

ReplyReceived

Occurs when a reply for is received to match a request sent from the container message broker.

Declaration
public event EventHandler<ReplyReceivedEventArgs> ReplyReceived
Event Type
Type Description
System.EventHandler<ReplyReceivedEventArgs>

Implements

ILoggable
IMessageRouter
System.IDisposable

Extension Methods

DynamicObjectExtensions.SetPropertyValue(Object, String, Object)
DynamicObjectExtensions.TrySetPropertyValue(Object, String, Object)
DynamicObjectExtensions.GetPropertyValue(Object, String)
DynamicObjectExtensions.TryGetPropertyValue(Object, String, out Object)
DynamicObjectExtensions.GetRuntimeTypeInfo(Object)
DynamicObjectExtensions.ToDynamic(Object)
DynamicObjectExtensions.ToExpando(Object)
BehaviorValue.ToBehaviorValue<TValue>(TValue)
CollectionExtensions.AddRange<T, TItem>(T, IEnumerable<TItem>)
LoggingExtensions.GetLogger(Object, IContext)
TypeExtensions.GetAbstractType(Object)
TypeExtensions.GetAbstractTypeInfo(Object)
ReflectionHelper.GetTypeInfo(Object)
EntityEntryExtensions.TryGetAttachedEntityEntry(Object)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX