Class GenericCommandMessage
- All Implemented Interfaces:
CommandMessage,Message
CommandMessage interface.- Since:
- 2.0.0
- Author:
- Allard Buijze, Steven van Beelen
-
Field Summary
Fields inherited from interface org.axonframework.messaging.core.Message
RESOURCE_KEY -
Constructor Summary
ConstructorsConstructorDescriptionGenericCommandMessage(Message delegate) Constructs aGenericCommandMessagewith givendelegate.GenericCommandMessage(Message delegate, String routingKey, Integer priority) Constructs aGenericCommandMessagewith givendelegate,routingKey, andpriority.GenericCommandMessage(MessageType type, Object payload) Constructs aGenericCommandMessagefor the giventypeandpayload.GenericCommandMessage(MessageType type, Object payload, Map<String, String> metadata) Constructs aGenericCommandMessagefor the giventype,payload, andmetadata.GenericCommandMessage(MessageType type, Object payload, Map<String, String> metadata, String routingKey, Integer priority) Constructs aGenericCommandMessagefor the giventype,payload, andmetadata. -
Method Summary
Modifier and TypeMethodDescriptionandMetadata(Map<String, String> metadata) protected voiddescribeTo(StringBuilder stringBuilder) Describe the message specific properties to the givenstringBuilder.protected StringDescribe the type of message, used inMessageDecorator.toString().priority()Returns the priority of thisCommandMessage, if any is applicable.Returns the routing key for this command message, if any is applicable.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.MessageDecorator
delegate, 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.CommandMessage
withConvertedPayload, withConvertedPayload
-
Constructor Details
-
GenericCommandMessage
Constructs aGenericCommandMessagefor the giventypeandpayload.The
Metadatadefaults to an empty instance.- Parameters:
type- Thetypefor thisCommandMessage.payload- The payload for thisCommandMessage.
-
GenericCommandMessage
public GenericCommandMessage(@Nonnull MessageType type, @Nullable Object payload, @Nonnull Map<String, String> metadata) Constructs aGenericCommandMessagefor the giventype,payload, andmetadata.- Parameters:
type- Thetypefor thisCommandMessage.payload- The payload for thisCommandMessage.metadata- The metadata for thisCommandMessage.
-
GenericCommandMessage
public GenericCommandMessage(@Nonnull MessageType type, @Nonnull Object payload, @Nonnull Map<String, String> metadata, @Nullable String routingKey, @Nullable Integer priority) Constructs aGenericCommandMessagefor the giventype,payload, andmetadata.Optionally, a
routingKeyand/or aprioritymay be passed.- Parameters:
type- Thetypefor thisCommandMessage.payload- The payload for thisCommandMessage.metadata- The metadata for thisCommandMessage.routingKey- The routing key for thisCommandMessage, if any.priority- The priority for thisCommandMessage, if any.
-
GenericCommandMessage
Constructs aGenericCommandMessagewith givendelegate.The
delegatewill be used supply thepayload,type,metadataandidentifierof the resultingGenericCommandMessage.Unlike the other constructors, this constructor will not attempt to retrieve any correlation data from the Unit of Work.
- Parameters:
delegate- TheMessagecontainingpayload,qualifiedName,identifierandmetadatafor theCommandMessageto reconstruct.
-
GenericCommandMessage
public GenericCommandMessage(@Nonnull Message delegate, @Nullable String routingKey, @Nullable Integer priority) Constructs aGenericCommandMessagewith givendelegate,routingKey, andpriority.The
delegatewill be used supply thepayload,type,metadataandidentifierof the resultingGenericCommandMessage.
Optionally, aroutingKeyand/or aprioritymay be passed.Unlike the other constructors, this constructor will not attempt to retrieve any correlation data from the Unit of Work.
- Parameters:
delegate- TheMessagecontainingpayload,qualifiedName,identifierandmetadatafor theCommandMessageto reconstruct.routingKey- The routing key for thisCommandMessage, if any.priority- The priority for thisCommandMessage, if any.
-
-
Method Details
-
routingKey
Description copied from interface:CommandMessageReturns 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.
- Specified by:
routingKeyin interfaceCommandMessage- Returns:
- The routing key for this command message, or an empty
Optionalif no routing key is set.
-
priority
Description copied from interface:CommandMessageReturns 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.
- Specified by:
priorityin interfaceCommandMessage- 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 interfaceCommandMessage- 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 interfaceCommandMessage- Specified by:
andMetadatain interfaceMessage- Parameters:
metadata- The metadata to merge with.- Returns:
- A copy of
this Message (implementation)with the givenmetadata.
-
withConvertedPayload
@Nonnull public CommandMessage 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 interfaceCommandMessage- Specified by:
withConvertedPayloadin interfaceMessage- Overrides:
withConvertedPayloadin classMessageDecorator- 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.
-
describeTo
Description copied from class:MessageDecoratorDescribe the message specific properties to the givenstringBuilder. Subclasses should override this method, calling the super method and appending their own properties to the end (or beginning).As convention, String values should be enclosed in single quotes, Objects in curly brackets and numeric values may be appended without enclosing. All properties should be preceded by a comma when appending, or finish with a comma when prefixing values.
- Overrides:
describeToin classMessageDecorator- Parameters:
stringBuilder- The builder to append data to.
-
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 classMessageDecorator- Returns:
- The type of the message.
-