Interface CommandMessage
- All Superinterfaces:
Message
- All Known Implementing Classes:
GenericCommandMessage
Message carrying a command as its payload.
These messages carry an intention to change application state.
- Since:
- 2.0.0
- Author:
- Allard Buijze
-
Field Summary
Fields inherited from interface org.axonframework.messaging.core.Message
RESOURCE_KEY -
Method Summary
Modifier and TypeMethodDescriptionandMetadata(Map<String, String> metadata) priority()Returns the priority of thisCommandMessage, if any is applicable.Returns the routing key for this command message, if any is applicable.default CommandMessagewithConvertedPayload(Class<?> type, Converter converter) Returns a newMessageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter.withConvertedPayload(Type type, Converter converter) Returns a newMessageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter.default CommandMessagewithConvertedPayload(TypeReference<?> type, Converter converter) Returns a newMessageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter.withMetadata(Map<String, String> metadata) Returns a copy of thisMessage(implementation) with the givenmetadata.
-
Method Details
-
routingKey
Returns the routing key for this command message, if any is applicable.Commands with the same routing key should be routed to the same handler if possible, as they are likely related and might have to be executed in a specific order.
- Returns:
- The routing key for this command message, or an empty
Optionalif no routing key is set.
-
priority
OptionalInt priority()Returns the priority of thisCommandMessage, if any is applicable.Commands with a higher priority should be handled before commands with a lower priority. Commands without a priority are considered to have the lowest priority.
- Returns:
- The priority of this command message, or an empty
OptionalIntif no priority is set.
-
withMetadata
Description copied from interface:MessageReturns a copy of thisMessage(implementation) with the givenmetadata.All other fields, like for example the
Message.payload(), remain unchanged.While the implementation returned may be different from the implementation of
this, implementations must take special care in returning the same type ofMessageto prevent errors further downstream.- Specified by:
withMetadatain interfaceMessage- Parameters:
metadata- The new metadata for theMessage.- Returns:
- A copy of
this Message (implementation)with the givenmetadata.
-
andMetadata
Description copied from interface:MessageReturns a copy of thisMessage(implementation) with itsmetadatamerged with the givenmetadata.All other fields, like for example the
Message.payload(), remain unchanged.- Specified by:
andMetadatain interfaceMessage- Parameters:
metadata- The metadata to merge with.- Returns:
- A copy of
this Message (implementation)with the givenmetadata.
-
withConvertedPayload
@Nonnull default CommandMessage withConvertedPayload(@Nonnull Class<?> type, @Nonnull Converter converter) Description copied from interface:MessageReturns a newMessageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter. This newMessageis effectively a copy ofthis Messagewith a renewed payload andMessage.payloadType().Will return the
thisinstance if thepayload typeisassignable fromthe converted result.- Specified by:
withConvertedPayloadin interfaceMessage- Parameters:
type- The type to convert theMessage.payload()to.converter- The converter to convert theMessage.payload()with.- Returns:
- A new
Messageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter.
-
withConvertedPayload
@Nonnull default CommandMessage withConvertedPayload(@Nonnull TypeReference<?> type, @Nonnull Converter converter) Description copied from interface:MessageReturns a newMessageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter. This newMessageis effectively a copy ofthis Messagewith a renewed payload andMessage.payloadType().Will return the
thisinstance if thepayload typeisassignable fromthe converted result.- Specified by:
withConvertedPayloadin interfaceMessage- Parameters:
type- The type to convert theMessage.payload()to.converter- The converter to convert theMessage.payload()with.- Returns:
- A new
Messageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter.
-
withConvertedPayload
Description copied from interface:MessageReturns a newMessageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter. This newMessageis effectively a copy ofthis Messagewith a renewed payload andMessage.payloadType().Will return the
thisinstance if thepayload typeisassignable fromthe converted result.- Specified by:
withConvertedPayloadin interfaceMessage- Parameters:
type- The type to convert theMessage.payload()to.converter- The converter to convert theMessage.payload()with.- Returns:
- A new
Messageimplementation with itsMessage.payload()converted to the giventypeby the givenconverter.
-