@Documented @Retention(value=RUNTIME) @Target(value={METHOD,CONSTRUCTOR,ANNOTATION_TYPE}) @MessageHandler(messageType=CommandMessage.class) public @interface CommandHandler
AnnotationCommandHandlerAdapter
to subscribe the annotated class to the command bus.
Alternatively, the annotations may be placed on an Aggregate members, in which case the AggregateAnnotationCommandHandler
can be used to subscribe the handlers to the command bus. When the annotation
appears on an Aggregate root's constructor, that command will cause a new aggregate to be created and stored in the
repository provided with the AggregateAnnotationCommandHandler
. If a non-root entity of the Aggregate is
to handle a command, the field declaring that entity must be annotated with AggregateMember
. Note that the CommandHandler
annotation may not
be placed on a non-root Entity's constructor.
The annotated method's first parameter is the command handled by that method. Optionally, the command handler may
specify a second parameter of type UnitOfWork
. The active Unit of Work will be
passed if that parameter is supplied.Modifier and Type | Optional Element and Description |
---|---|
String |
commandName
The name of the Command this handler listens to.
|
Class<?> |
payloadType
The type of payload expected by this handler.
|
String |
routingKey
The property of the command to be used as a routing key towards this command handler instance.
|
public abstract String commandName
public abstract String routingKey
public abstract Class<?> payloadType
Copyright © 2010–2017. All rights reserved.