Class AbstractMessageChannel
public abstract class AbstractMessageChannel : Channel<IMessage>, IMessageChannel, IServiceNameAware, IInterceptableChannel
- Inheritance
-
AbstractMessageChannel
- Implements
- Derived
- Inherited Members
Constructors
AbstractMessageChannel(ILogger)
public AbstractMessageChannel(ILogger logger = null)
Parameters
logger
ILogger
Fields
INDEFINITE_TIMEOUT
public const int INDEFINITE_TIMEOUT = -1
Field Value
Properties
Logger
public ILogger Logger { get; set; }
Property Value
ServiceName
public virtual string ServiceName { get; set; }
Property Value
Methods
AddInterceptor(IChannelInterceptor)
Add an interceptor to the list
public virtual void AddInterceptor(IChannelInterceptor interceptor)
Parameters
interceptor
IChannelInterceptorthe interceptor to add
AddInterceptor(int, IChannelInterceptor)
Add an interceptor at the location specified by the index
public virtual void AddInterceptor(int index, IChannelInterceptor interceptor)
Parameters
index
intthe index to add the interceptor at
interceptor
IChannelInterceptorthe interceptor to add
DoSend(IMessage, int)
protected virtual bool DoSend(IMessage message, int timeout)
Parameters
Returns
DoSend(IMessage, CancellationToken)
protected virtual bool DoSend(IMessage message, CancellationToken cancellationToken)
Parameters
message
IMessagecancellationToken
CancellationToken
Returns
DoSendInternal(IMessage, CancellationToken)
protected abstract bool DoSendInternal(IMessage message, CancellationToken cancellationToken)
Parameters
message
IMessagecancellationToken
CancellationToken
Returns
GetInterceptors()
Get the interceptors for the channel
public virtual List<IChannelInterceptor> GetInterceptors()
Returns
- List<IChannelInterceptor>
the list of interceptors
RemoveInterceptor(IChannelInterceptor)
Remove the specified interceptor
public virtual bool RemoveInterceptor(IChannelInterceptor interceptor)
Parameters
interceptor
IChannelInterceptorthe interceptor to remove
Returns
- bool
true if successful
RemoveInterceptor(int)
Remove the interceptor at the given index.
public virtual IChannelInterceptor RemoveInterceptor(int index)
Parameters
index
intthe index to use
Returns
- IChannelInterceptor
the interceptor removed
Send(IMessage)
Send a message to this channel. If the message is sent successfuly, the method returns true. If the message cannot be sent due to a non-fatal reason, the method returns false. The method may also throw a Exception in case of non-recoverable errors. This method may block indefinitely, depending on the implementation.
public virtual bool Send(IMessage message)
Parameters
message
IMessagethe message to send
Returns
- bool
true if the message is sent
Send(IMessage, int)
Send a message, blocking until either the message is accepted or the specified timeout period elapses.
public virtual bool Send(IMessage message, int timeout)
Parameters
Returns
- bool
true if the message is sent
SendAsync(IMessage, CancellationToken)
Send a message to this channel.
public virtual ValueTask<bool> SendAsync(IMessage message, CancellationToken cancellationToken = default)
Parameters
message
IMessagethe message to send
cancellationToken
CancellationTokentoken used to signal cancellation
Returns
SetInterceptors(List<IChannelInterceptor>)
Set the list of channel interceptors
public virtual void SetInterceptors(List<IChannelInterceptor> interceptors)
Parameters
interceptors
List<IChannelInterceptor>the interceptors to use
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.