Class QueuedCommandBusReceiver<TAuthenticationToken>
Receives instances of a ICommand<TAuthenticationToken> from the command bus, places them into one of several internal concurrent queues and then processes the commands one at a time per queue.
Inheritance
Inherited Members
Namespace: Cqrs.Bus
Assembly: Cqrs.dll
Syntax
public abstract class QueuedCommandBusReceiver<TAuthenticationToken> : ICommandReceiver<TAuthenticationToken>, ICommandReceiver
Type Parameters
Name | Description |
---|---|
TAuthenticationToken | The System.Type of authentication token. |
Constructors
QueuedCommandBusReceiver(IAuthenticationTokenHelper<TAuthenticationToken>, ICorrelationIdHelper, ILogger, IConfigurationManager, IBusHelper)
Instantiates a new instance of QueuedCommandBusReceiver<TAuthenticationToken>.
Declaration
protected QueuedCommandBusReceiver(IAuthenticationTokenHelper<TAuthenticationToken> authenticationTokenHelper, ICorrelationIdHelper correlationIdHelper, ILogger logger, IConfigurationManager configurationManager, IBusHelper busHelper)
Parameters
Type | Name | Description |
---|---|---|
IAuthenticationTokenHelper<TAuthenticationToken> | authenticationTokenHelper | |
cdmdotnet.Logging.ICorrelationIdHelper | correlationIdHelper | |
cdmdotnet.Logging.ILogger | logger | |
IConfigurationManager | configurationManager | |
IBusHelper | busHelper |
Properties
AuthenticationTokenHelper
Gets or sets the IAuthenticationTokenHelper<TAuthenticationToken>
Declaration
protected IAuthenticationTokenHelper<TAuthenticationToken> AuthenticationTokenHelper { get; }
Property Value
Type | Description |
---|---|
IAuthenticationTokenHelper<TAuthenticationToken> |
BusHelper
Gets or sets the IBusHelper
Declaration
protected IBusHelper BusHelper { get; }
Property Value
Type | Description |
---|---|
IBusHelper |
ConfigurationManager
Gets or sets the IConfigurationManager
Declaration
protected IConfigurationManager ConfigurationManager { get; }
Property Value
Type | Description |
---|---|
IConfigurationManager |
CorrelationIdHelper
Gets or sets the cdmdotnet.Logging.ICorrelationIdHelper
Declaration
protected ICorrelationIdHelper CorrelationIdHelper { get; }
Property Value
Type | Description |
---|---|
cdmdotnet.Logging.ICorrelationIdHelper |
Logger
Gets or sets the cdmdotnet.Logging.ILogger
Declaration
protected ILogger Logger { get; }
Property Value
Type | Description |
---|---|
cdmdotnet.Logging.ILogger |
QueueCount
The current number of queues in QueueTracker.
Declaration
public int QueueCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
QueueNames
Gets the names of all queues in QueueTracker.
Declaration
public ICollection<string> QueueNames { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.String> |
QueueTracker
The queues keyed by an identifier.
Declaration
protected static ConcurrentDictionary<string, ConcurrentQueue<ICommand<TAuthenticationToken>>> QueueTracker { get; }
Property Value
Type | Description |
---|---|
System.Collections.Concurrent.ConcurrentDictionary<System.String, System.Collections.Concurrent.ConcurrentQueue<ICommand<TAuthenticationToken>>> |
QueueTrackerLock
A System.Threading.ReaderWriterLockSlim for providing a lock mechanism around the main QueueTracker.
Declaration
protected ReaderWriterLockSlim QueueTrackerLock { get; }
Property Value
Type | Description |
---|---|
System.Threading.ReaderWriterLockSlim |
Routes
Gets or sets the routes or handlers that will be executed as the commands arrive.
Declaration
protected abstract IDictionary<Type, IList<Action<IMessage>>> Routes { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Type, System.Collections.Generic.IList<System.Action<IMessage>>> |
Methods
CreateQueueAndAttachListenerIfNotExist(String)
Checks if the queue exists, if it doesn't it creates a new queue in QueueTracker and then starts a separate System.Threading.Thread running DequeuAndProcessCommand(String).
Declaration
protected virtual void CreateQueueAndAttachListenerIfNotExist(string queueName)
Parameters
Type | Name | Description |
---|---|---|
System.String | queueName | The name of the queue. |
DequeuAndProcessCommand(String)
Infinitely runs a loop checking if the queue exists in QueueTracker and then dequeues ICommand<TAuthenticationToken> one at a time, pausing for 0.1 seconds between loops.
Declaration
protected virtual void DequeuAndProcessCommand(string queueName)
Parameters
Type | Name | Description |
---|---|---|
System.String | queueName | The name of the queue. |
EnqueueCommand(String, ICommand<TAuthenticationToken>)
Places the provided command
into the appropriate queue in the QueueTracker.
Declaration
protected virtual void EnqueueCommand(string targetQueueName, ICommand<TAuthenticationToken> command)
Parameters
Type | Name | Description |
---|---|---|
System.String | targetQueueName | The name of the target queue to place the command into |
ICommand<TAuthenticationToken> | command | The ICommand<TAuthenticationToken> to handle. |
ReceiveCommand(ICommand<TAuthenticationToken>)
Receives a ICommand<TAuthenticationToken> from the command bus.
Declaration
public virtual bool ? ReceiveCommand(ICommand<TAuthenticationToken> command)
Parameters
Type | Name | Description |
---|---|---|
ICommand<TAuthenticationToken> | command |
Returns
Type | Description |
---|---|
System.Nullable<System.Boolean> |
Implements
Start()
Starts listening and processing instances of ICommand<TAuthenticationToken> from the command bus.
Declaration
public abstract void Start()