Class GenericCommandResultMessage
- All Implemented Interfaces:
CommandResultMessage,Message,ResultMessage
CommandResultMessage interface.- Since:
- 4.0.0
- Author:
- Milan Savic, Steven van Beelen
-
Field Summary
Fields inherited from interface org.axonframework.messaging.core.Message
RESOURCE_KEY -
Constructor Summary
ConstructorsConstructorDescriptionGenericCommandResultMessage(Message delegate) Constructs aGenericCommandResultMessagefor the givendelegate, intended to reconstruct anotherCommandResultMessage.GenericCommandResultMessage(MessageType type, Object commandResult) GenericCommandResultMessage(MessageType type, Object commandResult, Map<String, String> metadata) Constructs aGenericCommandResultMessagefor the giventype,commandResult, andmetadata.GenericCommandResultMessage(MessageType type, Throwable exception) Deprecated.GenericCommandResultMessage(MessageType type, Throwable exception, Map<String, String> metadata) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionandMetadata(Map<String, String> metadata) protected StringDescribe the type of message, used inMessageDecorator.toString().withConvertedPayload(Type 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.Methods inherited from class org.axonframework.messaging.core.GenericResultMessage
asResultMessageMethods inherited from class org.axonframework.messaging.core.MessageDecorator
delegate, describeTo, identifier, metadata, payload, payloadAs, payloadType, toString, typeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.axonframework.messaging.commandhandling.CommandResultMessage
withConvertedPayload, withConvertedPayload
-
Constructor Details
-
GenericCommandResultMessage
Constructs aGenericResultMessagefor the giventypeandcommandResult.Uses the correlation data of the current Unit of Work, if present.
- Parameters:
type- Thetypefor thisCommandResultMessage.commandResult- The result for thisCommandResultMessage.
-
GenericCommandResultMessage
@Deprecated public GenericCommandResultMessage(@Nonnull MessageType type, @Nonnull Throwable exception) Deprecated.Constructs aGenericCommandResultMessagefor the giventypeandexception.Uses the correlation data of the current Unit of Work, if present.
- Parameters:
type- Thetypefor thisCommandResultMessage.exception- TheThrowabledescribing the error representing the response of thisCommandResultMessage.
-
GenericCommandResultMessage
public GenericCommandResultMessage(@Nonnull MessageType type, @Nullable Object commandResult, @Nonnull Map<String, String> metadata) Constructs aGenericCommandResultMessagefor the giventype,commandResult, andmetadata.- Parameters:
type- Thetypefor thisCommandResultMessage.commandResult- The result for thisCommandResultMessage.metadata- The metadata for thisCommandResultMessage.
-
GenericCommandResultMessage
@Deprecated public GenericCommandResultMessage(@Nonnull MessageType type, @Nonnull Throwable exception, @Nonnull Map<String, String> metadata) Deprecated.Constructs aGenericCommandResultMessagefor the giventype,exception, andmetadata.- Parameters:
type- Thetypefor thisCommandResultMessage.exception- TheThrowabledescribing the error representing the response of thisCommandResultMessage.metadata- The metadata for thisCommandResultMessage.
-
GenericCommandResultMessage
Constructs aGenericCommandResultMessagefor the givendelegate, intended to reconstruct anotherCommandResultMessage.Unlike the other constructors, this constructor will not attempt to retrieve any correlation data from the Unit of Work.
- Parameters:
delegate- TheMessagecontainingpayload,type,identifierandmetadatafor theQueryResponseMessageto reconstruct.
-
-
Method Details
-
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 interfaceCommandResultMessage- Specified by:
withMetadatain interfaceMessage- Specified by:
withMetadatain interfaceResultMessage- Overrides:
withMetadatain classGenericResultMessage- 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 interfaceCommandResultMessage- Specified by:
andMetadatain interfaceMessage- Specified by:
andMetadatain interfaceResultMessage- Overrides:
andMetadatain classGenericResultMessage- Parameters:
metadata- The metadata to merge with.- Returns:
- A copy of
this Message (implementation)with the givenmetadata.
-
withConvertedPayload
@Nonnull public CommandResultMessage withConvertedPayload(@Nonnull Type 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 interfaceCommandResultMessage- Specified by:
withConvertedPayloadin interfaceMessage- Specified by:
withConvertedPayloadin interfaceResultMessage- Overrides:
withConvertedPayloadin classGenericResultMessage- 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.
-
describeType
Description copied from class:MessageDecoratorDescribe the type of message, used inMessageDecorator.toString().Defaults to the simple class name of the actual instance.
- Overrides:
describeTypein classGenericResultMessage- Returns:
- The type of the message.
-