Class AkkaCommandBus<TAuthenticationToken>
A ICommandPublisher<TAuthenticationToken> that resolves handlers , executes the handler and then publishes the ICommand<TAuthenticationToken> on the public command bus.
Inheritance
Inherited Members
Namespace: Cqrs.Akka.Commands
Assembly: Cqrs.Akka.dll
Syntax
public class AkkaCommandBus<TAuthenticationToken> : IAkkaCommandPublisher<TAuthenticationToken>, IPublishAndWaitCommandPublisher<TAuthenticationToken>, ICommandPublisher<TAuthenticationToken>, ICommandHandlerRegistrar, IHandlerRegistrar
Type Parameters
Name | Description |
---|---|
TAuthenticationToken | The System.Type of the authentication token. |
Constructors
AkkaCommandBus(IBusHelper, IAuthenticationTokenHelper<TAuthenticationToken>, ICorrelationIdHelper, IDependencyResolver, ILogger, ICommandPublisher<TAuthenticationToken>, ICommandReceiver<TAuthenticationToken>)
Instantiates a new instance of AkkaCommandBus<TAuthenticationToken>
Declaration
public AkkaCommandBus(IBusHelper busHelper, IAuthenticationTokenHelper<TAuthenticationToken> authenticationTokenHelper, ICorrelationIdHelper correlationIdHelper, IDependencyResolver dependencyResolver, ILogger logger, ICommandPublisher<TAuthenticationToken> commandPublisher, ICommandReceiver<TAuthenticationToken> commandReceiver)
Parameters
Type | Name | Description |
---|---|---|
IBusHelper | busHelper | |
IAuthenticationTokenHelper<TAuthenticationToken> | authenticationTokenHelper | |
cdmdotnet.Logging.ICorrelationIdHelper | correlationIdHelper | |
IDependencyResolver | dependencyResolver | |
cdmdotnet.Logging.ILogger | logger | |
ICommandPublisher<TAuthenticationToken> | commandPublisher | |
ICommandReceiver<TAuthenticationToken> | commandReceiver |
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 |
CommandPublisher
Gets or sets the ICommandPublisher<TAuthenticationToken>
Declaration
protected ICommandPublisher<TAuthenticationToken> CommandPublisher { get; }
Property Value
Type | Description |
---|---|
ICommandPublisher<TAuthenticationToken> |
CommandReceiver
Gets or sets the ICommandReceiver<TAuthenticationToken>
Declaration
protected ICommandReceiver<TAuthenticationToken> CommandReceiver { get; }
Property Value
Type | Description |
---|---|
ICommandReceiver<TAuthenticationToken> |
CorrelationIdHelper
Gets or sets the cdmdotnet.Logging.ICorrelationIdHelper
Declaration
protected ICorrelationIdHelper CorrelationIdHelper { get; }
Property Value
Type | Description |
---|---|
cdmdotnet.Logging.ICorrelationIdHelper |
DependencyResolver
Gets or sets the IDependencyResolver
Declaration
protected IDependencyResolver DependencyResolver { get; }
Property Value
Type | Description |
---|---|
IDependencyResolver |
EventWaits
Gets or sets the current list of events waiting to be evaluated for PublishAndWait<TCommand, TEvent>(TCommand, IEventReceiver<TAuthenticationToken>)
Declaration
protected IDictionary<Guid, IList<IEvent<TAuthenticationToken>>> EventWaits { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Guid, System.Collections.Generic.IList<IEvent<TAuthenticationToken>>> |
Logger
Gets or sets the cdmdotnet.Logging.ILogger
Declaration
protected ILogger Logger { get; }
Property Value
Type | Description |
---|---|
cdmdotnet.Logging.ILogger |
Routes
Gets the RouteManager
Declaration
protected static RouteManager Routes { get; }
Property Value
Type | Description |
---|---|
RouteManager |
Methods
PrepareAndValidateCommand<TCommand>(TCommand, out RouteHandlerDelegate)
Locates a suitable ICommandValidator<TAuthenticationToken, TCommand> to validate the provided command
and validates the provided command
if one is located
Calls PrepareCommand<TCommand>(TCommand)
Checks if the provided command
is required to be processed
Locates a single RouteHandlerDelegate for the provided command
Declaration
protected virtual bool PrepareAndValidateCommand<TCommand>(TCommand command, out RouteHandlerDelegate commandHandler)where TCommand : ICommand<TAuthenticationToken>
Parameters
Type | Name | Description |
---|---|---|
TCommand | command | |
RouteHandlerDelegate | commandHandler |
Returns
Type | Description |
---|---|
System.Boolean | False if a suitable ICommandValidator<TAuthenticationToken, TCommand> is located and the provided |
Type Parameters
Name | Description |
---|---|
TCommand |
PrepareCommand<TCommand>(TCommand)
Sets the AuthenticationToken, CorrelationId, OriginatingFramework to "Akka" and adds a value of "Akka" to the Frameworks if not already done so
Declaration
protected virtual void PrepareCommand<TCommand>(TCommand command)where TCommand : ICommand<TAuthenticationToken>
Parameters
Type | Name | Description |
---|---|---|
TCommand | command |
Type Parameters
Name | Description |
---|---|
TCommand |
Publish<TCommand>(TCommand)
Publishes the provided command
on the command bus.
Declaration
public virtual void Publish<TCommand>(TCommand command)where TCommand : ICommand<TAuthenticationToken>
Parameters
Type | Name | Description |
---|---|---|
TCommand | command |
Type Parameters
Name | Description |
---|---|
TCommand |
Implements
Publish<TCommand>(IEnumerable<TCommand>)
Publishes the provided commands
on the command bus.
Declaration
public virtual void Publish<TCommand>(IEnumerable<TCommand> commands)where TCommand : ICommand<TAuthenticationToken>
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TCommand> | commands |
Type Parameters
Name | Description |
---|---|
TCommand |
Implements
PublishAndWait<TCommand, TEvent>(TCommand, IEventReceiver<TAuthenticationToken>)
Publishes the provided command
and waits for an event of TEvent
Declaration
public virtual TEvent PublishAndWait<TCommand, TEvent>(TCommand command, IEventReceiver<TAuthenticationToken> eventReceiver = null)where TCommand : ICommand<TAuthenticationToken>
Parameters
Type | Name | Description |
---|---|---|
TCommand | command | The |
IEventReceiver<TAuthenticationToken> | eventReceiver | If provided, is the IEventReceiver<TAuthenticationToken> that the event is expected to be returned on. |
Returns
Type | Description |
---|---|
TEvent |
Type Parameters
Name | Description |
---|---|
TCommand | |
TEvent |
Implements
PublishAndWait<TCommand, TEvent>(TCommand, Func<IEnumerable<IEvent<TAuthenticationToken>>, TEvent>, IEventReceiver<TAuthenticationToken>)
Publishes the provided command
and waits until the specified condition is satisfied an event of TEvent
Declaration
public virtual TEvent PublishAndWait<TCommand, TEvent>(TCommand command, Func<IEnumerable<IEvent<TAuthenticationToken>>, TEvent> condition, IEventReceiver<TAuthenticationToken> eventReceiver = null)where TCommand : ICommand<TAuthenticationToken>
Parameters
Type | Name | Description |
---|---|---|
TCommand | command | The |
System.Func<System.Collections.Generic.IEnumerable<IEvent<TAuthenticationToken>>, TEvent> | condition | A delegate to be executed over and over until it returns the |
IEventReceiver<TAuthenticationToken> | eventReceiver | If provided, is the IEventReceiver<TAuthenticationToken> that the event is expected to be returned on. |
Returns
Type | Description |
---|---|
TEvent |
Type Parameters
Name | Description |
---|---|
TCommand | |
TEvent |
Implements
PublishAndWait<TCommand, TEvent>(TCommand, Func<IEnumerable<IEvent<TAuthenticationToken>>, TEvent>, Int32, IEventReceiver<TAuthenticationToken>)
Publishes the provided command
and waits for an event of TEvent
or exits if the specified timeout is expired.
Declaration
public virtual TEvent PublishAndWait<TCommand, TEvent>(TCommand command, Func<IEnumerable<IEvent<TAuthenticationToken>>, TEvent> condition, int millisecondsTimeout, IEventReceiver<TAuthenticationToken> eventReceiver = null)where TCommand : ICommand<TAuthenticationToken>
Parameters
Type | Name | Description |
---|---|---|
TCommand | command | The |
System.Func<System.Collections.Generic.IEnumerable<IEvent<TAuthenticationToken>>, TEvent> | condition | A delegate to be executed over and over until it returns the |
System.Int32 | millisecondsTimeout | The number of milliseconds to wait, or System.Threading.Timeout.Infinite (-1) to wait indefinitely. |
IEventReceiver<TAuthenticationToken> | eventReceiver | If provided, is the IEventReceiver<TAuthenticationToken> that the event is expected to be returned on. |
Returns
Type | Description |
---|---|
TEvent |
Type Parameters
Name | Description |
---|---|
TCommand | |
TEvent |
Implements
PublishAndWait<TCommand, TEvent>(TCommand, Func<IEnumerable<IEvent<TAuthenticationToken>>, TEvent>, TimeSpan, IEventReceiver<TAuthenticationToken>)
Publishes the provided command
and waits for an event of TEvent
or exits if the specified timeout is expired.
Declaration
public virtual TEvent PublishAndWait<TCommand, TEvent>(TCommand command, Func<IEnumerable<IEvent<TAuthenticationToken>>, TEvent> condition, TimeSpan timeout, IEventReceiver<TAuthenticationToken> eventReceiver = null)where TCommand : ICommand<TAuthenticationToken>
Parameters
Type | Name | Description |
---|---|---|
TCommand | command | The |
System.Func<System.Collections.Generic.IEnumerable<IEvent<TAuthenticationToken>>, TEvent> | condition | A delegate to be executed over and over until it returns the |
System.TimeSpan | timeout | A System.TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely. |
IEventReceiver<TAuthenticationToken> | eventReceiver | If provided, is the IEventReceiver<TAuthenticationToken> that the event is expected to be returned on. |
Returns
Type | Description |
---|---|
TEvent |
Type Parameters
Name | Description |
---|---|
TCommand | |
TEvent |
Implements
PublishAndWait<TCommand, TEvent>(TCommand, Int32, IEventReceiver<TAuthenticationToken>)
Publishes the provided command
and waits for an event of TEvent
or exits if the specified timeout is expired.
Declaration
public virtual TEvent PublishAndWait<TCommand, TEvent>(TCommand command, int millisecondsTimeout, IEventReceiver<TAuthenticationToken> eventReceiver = null)where TCommand : ICommand<TAuthenticationToken>
Parameters
Type | Name | Description |
---|---|---|
TCommand | command | The |
System.Int32 | millisecondsTimeout | The number of milliseconds to wait, or System.Threading.Timeout.Infinite (-1) to wait indefinitely. |
IEventReceiver<TAuthenticationToken> | eventReceiver | If provided, is the IEventReceiver<TAuthenticationToken> that the event is expected to be returned on. |
Returns
Type | Description |
---|---|
TEvent |
Type Parameters
Name | Description |
---|---|
TCommand | |
TEvent |
Implements
PublishAndWait<TCommand, TEvent>(TCommand, TimeSpan, IEventReceiver<TAuthenticationToken>)
Publishes the provided command
and waits for an event of TEvent
or exits if the specified timeout is expired.
Declaration
public virtual TEvent PublishAndWait<TCommand, TEvent>(TCommand command, TimeSpan timeout, IEventReceiver<TAuthenticationToken> eventReceiver = null)where TCommand : ICommand<TAuthenticationToken>
Parameters
Type | Name | Description |
---|---|---|
TCommand | command | The |
System.TimeSpan | timeout | A System.TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely. |
IEventReceiver<TAuthenticationToken> | eventReceiver | If provided, is the IEventReceiver<TAuthenticationToken> that the event is expected to be returned on. |
Returns
Type | Description |
---|---|
TEvent |
Type Parameters
Name | Description |
---|---|
TCommand | |
TEvent |
Implements
RegisterHandler<TMessage>(Action<TMessage>, Boolean)
Register an event or command handler that will listen and respond to events or commands.
Declaration
public void RegisterHandler<TMessage>(Action<TMessage> handler, bool holdMessageLock = true)where TMessage : IMessage
Parameters
Type | Name | Description |
---|---|---|
System.Action<TMessage> | handler | |
System.Boolean | holdMessageLock |
Type Parameters
Name | Description |
---|---|
TMessage |
Implements
RegisterHandler<TMessage>(Action<TMessage>, Type, Boolean)
Register an event or command handler that will listen and respond to events or commands.
Declaration
public void RegisterHandler<TMessage>(Action<TMessage> handler, Type targetedType, bool holdMessageLock = true)where TMessage : IMessage
Parameters
Type | Name | Description |
---|---|---|
System.Action<TMessage> | handler | |
System.Type | targetedType | |
System.Boolean | holdMessageLock |
Type Parameters
Name | Description |
---|---|
TMessage |