Supported Parameters for Annotated Handlers
This chapter provides an exhaustive list of all the possible parameters for annotated message handling functions. The parameters for any message handling function are resolved through an Axon Framework internal mechanism, called the ParameterResolver.
The set of ParameterResolvers can be extended if custom (or not yet) supported parameters should be injected in to your annotated handlers. For more specifics on configuring custom ParameterResolvers we suggest reading this section.
Supported Parameters for Command Handlers
By default, @CommandHandler annotated methods allow the following parameter types:
The first parameter is the payload of the command message.
It may also be of type
MessageorCommandMessage, if the@CommandHandlerannotation explicitly defined the name of the command the handler can process.By default, a command name is the fully qualified class name of the command its payload.
Parameters annotated with
@MetaDataValuewill resolve to the metadata value with the key as indicated on the annotation.If
requiredisfalse(default),nullis passed when the metadata value is not present.If
requiredistrue, the resolver will not match and prevent the method from being invoked when the metadata value is not present.Parameters of type
MetaDatawill have the entireMetaDataof aCommandMessageinjected.Parameters of type
UnitOfWorkget the current unit of work injected. This allows command handlers to register actions to be performed at specific stages of the Unit of Work, or gain access to the resources registered with it.Parameters of type
Message, orCommandMessagewill get the complete message, with both the payload and the metadata.This is useful if a method needs several metadata fields, or other properties of the wrapping Message.
A parameter of type
Stringannotated with@MessageIdentifierwill resolve the identifier of theCommandMessagebeing handledParameters of type
ConflictResolverwill resolve the configuredConflictResolverinstance.See the Conflict Resolution section for specifics on this topic.
Parameters of type
InterceptorChainwill resolve the chain ofMessageHandlerInterceptors for aCommandMessage.This feature should be used in conjunction with a
@CommandHandlerInterceptorannotated method.For more specifics on this it is recommend to read this section.
If the application is run in a Spring environment, any Spring Bean can be resolved.
Note that the
@Qualifierannotation can be used in conjunction with this to further specify which Bean should be resolved.
Supported Parameters for Query Handlers
By default, @QueryHandler annotated methods allow the following parameter types:
The first parameter is the payload of the query message.
It may also be of type
MessageorQueryMessage, if the@QueryHandlerannotation explicitly defined the name of the query the handler can process.By default, a query name is the fully qualified class name of the query its payload.
Parameters annotated with
@MetaDataValuewill resolve to the metadata value with the key as indicated on the annotation.If
requiredisfalse(default),nullis passed when the metadata value is not present.If
requiredistrue, the resolver will not match and prevent the method from being invoked when the metadata value is not present.Parameters of type
MetaDatawill have the entire metadata of aQueryMessageinjected.Parameters of type
UnitOfWorkget the current unit of work injected. This allows query handlers to register actions to be performed at specific stages of the unit of work, or gain access to the resources registered with it.Parameters of type
Message, orQueryMessagewill get the complete message, with both the payload and the metadata.This is useful if a method needs several meta data fields, or other properties of the wrapping message.
A parameter of type
Stringannotated with@MessageIdentifierwill resolve the identifier of theQueryMessagebeing handledIf the application is run in a Spring environment, any Spring Bean can be resolved.
Note that the
@Qualifierannotation can be used in conjunction with this to further specify which Bean should be resolved.
Last updated
Was this helpful?