Class GenericQueryMessage

java.lang.Object
org.axonframework.messaging.core.MessageDecorator
org.axonframework.messaging.queryhandling.GenericQueryMessage
All Implemented Interfaces:
Message, QueryMessage

public class GenericQueryMessage extends MessageDecorator implements QueryMessage
Generic implementation of the QueryMessage interface.
Since:
3.1.0
Author:
Marc Gathier, Steven van Beelen
  • Constructor Details

    • GenericQueryMessage

      public GenericQueryMessage(@Nonnull MessageType type, @Nullable Object payload)
      Constructs a GenericQueryMessage for the given type, payload, and responseType.

      The Metadata defaults to an empty instance. Initializes the message with the given payload and expected responseType.

      Parameters:
      type - The type for this QueryMessage.
      payload - The payload expressing the query for this CommandMessage.
    • GenericQueryMessage

      public GenericQueryMessage(@Nonnull Message delegate)
      Constructs a GenericQueryMessage with given delegate and responseType.

      The delegate will be used supply the payload, type, metadata and identifier of the resulting GenericQueryMessage.

      Unlike the other constructors, this constructor will not attempt to retrieve any correlation data from the Unit of Work.

      Parameters:
      delegate - The Message containing payload, type, identifier and metadata for the QueryMessage to reconstruct.
      See Also:
      • invalid reference
        GenericQueryMessage(Message, MessageType, Integer)
    • GenericQueryMessage

      public GenericQueryMessage(@Nonnull Message delegate, @Nullable Integer priority)
      Constructs a GenericQueryMessage with given delegate, responseType and priority.

      The delegate will be used supply the payload, type, metadata and identifier of the resulting GenericQueryMessage.

      Unlike the other constructors, this constructor will not attempt to retrieve any correlation data from the Unit of Work.

      Parameters:
      delegate - The Message containing payload, type, identifier and metadata for the QueryMessage to reconstruct.
      priority - The priority of this query message. May be null to indicate no priority.
  • Method Details

    • withMetadata

      @Nonnull public QueryMessage withMetadata(@Nonnull Map<String,String> metadata)
      Description copied from interface: Message
      Returns a copy of this Message (implementation) with the given metadata.

      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 of Message to prevent errors further downstream.

      Specified by:
      withMetadata in interface Message
      Specified by:
      withMetadata in interface QueryMessage
      Parameters:
      metadata - The new metadata for the Message.
      Returns:
      A copy of this Message (implementation) with the given metadata.
    • andMetadata

      @Nonnull public QueryMessage andMetadata(@Nonnull Map<String,String> metadata)
      Description copied from interface: Message
      Returns a copy of this Message (implementation) with its metadata merged with the given metadata.

      All other fields, like for example the Message.payload(), remain unchanged.

      Specified by:
      andMetadata in interface Message
      Specified by:
      andMetadata in interface QueryMessage
      Parameters:
      metadata - The metadata to merge with.
      Returns:
      A copy of this Message (implementation) with the given metadata.
    • withConvertedPayload

      @Nonnull public QueryMessage withConvertedPayload(@Nonnull Type type, @Nonnull Converter converter)
      Description copied from interface: Message
      Returns a new Message implementation with its Message.payload() converted to the given type by the given converter. This new Message is effectively a copy of this Message with a renewed payload and Message.payloadType().

      Will return the this instance if the payload type is assignable from the converted result.

      Specified by:
      withConvertedPayload in interface Message
      Specified by:
      withConvertedPayload in interface QueryMessage
      Overrides:
      withConvertedPayload in class MessageDecorator
      Parameters:
      type - The type to convert the Message.payload() to.
      converter - The converter to convert the Message.payload() with.
      Returns:
      A new Message implementation with its Message.payload() converted to the given type by the given converter.
    • priority

      public OptionalInt priority()
      Description copied from interface: QueryMessage
      Returns the priority of this QueryMessage, if any is applicable.

      Queries with a higher priority should be handled before queries with a lower priority. Queries without a priority are considered to have the lowest priority.

      Specified by:
      priority in interface QueryMessage
      Returns:
      The priority of this query message, or an empty OptionalInt if no priority is set.
    • describeTo

      protected void describeTo(StringBuilder stringBuilder)
      Description copied from class: MessageDecorator
      Describe the message specific properties to the given stringBuilder. 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:
      describeTo in class MessageDecorator
      Parameters:
      stringBuilder - The builder to append data to.
    • describeType

      protected String describeType()
      Description copied from class: MessageDecorator
      Describe the type of message, used in MessageDecorator.toString().

      Defaults to the simple class name of the actual instance.

      Overrides:
      describeType in class MessageDecorator
      Returns:
      The type of the message.