Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Has anyone got any samples or good ideas on exposing the command handler part of a CQRS framework through REST?

Ideally I'd like some way of generating the routing table "auto-magically" from the ICommand implementing classes - any thoughts?

The command definition interface looks like:-

VB
''' <summary>
''' Interface for any class that is a definition of a command to be passed to the command handler
''' </summary>
''' <remarks>
''' Because the command handler uses IoC, each command must have its own distinct definition class.
''' This interface and the CommandDefinitionBase class allow for common functionality to be enforced
''' across these classes.
''' </remarks>
Public Interface ICommandDefinition

    ''' <summary>
    ''' The unique key by which this command instance can be identified
    ''' </summary>
    ''' <remarks>
    ''' This allows commands to be persisted and for the command handler to record whether or not it has
    ''' executed a given command.  This should not be assumed to be sequential.
    ''' </remarks>
    ReadOnly Property InstanceIdentifier As Guid

    ''' <summary>
    ''' The human-readable name of the command
    ''' </summary>
    ''' <remarks>
    ''' For a high-frequency or low data use scenario an enumerated type can be used but for most cases a readable text
    ''' name for the command is preferable.
    ''' </remarks>
    ReadOnly Property CommandName As String

    ''' <summary>
    ''' Add a parameter to the list of parameters for this command
    ''' </summary>
    ''' <param name="name">
    ''' The name of the parameter to add
    ''' </param>
    ''' <param name="value">
    ''' The value to use for the parameter
    ''' </param>
    ''' <remarks></remarks>
    Sub AddParameter(ByVal name As String, ByVal value As Object)

    ''' <summary>
    ''' The set of parameters for this command
    ''' </summary>
    ''' <remarks>
    ''' This may be null to indicate that a command has no parameters
    ''' </remarks>
    ReadOnly Property Parameters As IEnumerable(Of CommandParameter)

    ''' <summary>
    ''' If the named parameter exists, return it, otherwise return false
    ''' </summary>
    ''' <typeparam name="TParameter">
    ''' The type of the value the parameter holds (string, decimal, boolean etc.)
    ''' </typeparam>
    ''' <param name="parameterName">
    ''' The name of the parameter to get
    ''' </param>
    ''' <param name="value">
    ''' The object that gets filled from the parameter if it exists
    ''' </param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function TryGetParameter(Of TParameter)(parameterName As String, ByRef value As TParameter) As Boolean

    ''' <summary>
    ''' If this command is retried this many times or more, consider it a poison message
    ''' </summary>
    ''' <remarks>
    ''' This may overriden by the command processor, or a specific command definition
    ''' </remarks>
    ReadOnly Property RecomendedPoisonMessageCeiling As Integer

    ''' <summary>
    ''' The token to use to prove the user specified sent this command
    ''' </summary>
    ''' <remarks>
    ''' This allows the command handler to discard any unauthorised commands
    ''' </remarks>
    ReadOnly Property AuthorisationToken As String

    ''' <summary>
    ''' The identifier of the user that issued the command
    ''' </summary>
    ''' <remarks>
    ''' This is used along with the authorisation token to decide if a command should be executed or not
    ''' </remarks>
    ReadOnly Property UserIdentifier As String


End Interface


and I could add to it to define the base URI of the command...?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900