Class GenericQueryMessage<T,R>

java.lang.Object
org.axonframework.messaging.MessageDecorator<T>
org.axonframework.queryhandling.GenericQueryMessage<T,R>
Type Parameters:
T - The type of payload expressing the query in this message
R - The type of response expected from this query
All Implemented Interfaces:
Serializable, Message<T>, QueryMessage<T,R>
Direct Known Subclasses:
GenericStreamingQueryMessage, GenericSubscriptionQueryMessage

public class GenericQueryMessage<T,R> extends MessageDecorator<T> implements QueryMessage<T,R>
Generic implementation of the QueryMessage. Unless explicitly provided, it assumes the queryName of the message is the fully qualified class name of the message's payload.
Since:
3.1
Author:
Marc Gathier
See Also:
  • Constructor Details

    • GenericQueryMessage

      public GenericQueryMessage(T payload, ResponseType<R> responseType)
      Initializes the message with the given payload and expected responseType. The query name is set to the fully qualified class name of the payload.
      Parameters:
      payload - The payload expressing the query
      responseType - The expected response type of type ResponseType
    • GenericQueryMessage

      public GenericQueryMessage(T payload, String queryName, ResponseType<R> responseType)
      Initializes the message with the given payload, queryName and expected responseType.
      Parameters:
      payload - The payload expressing the query
      queryName - The name identifying the query to execute
      responseType - The expected response type of type ResponseType
    • GenericQueryMessage

      public GenericQueryMessage(Message<T> delegate, String queryName, ResponseType<R> responseType)
      Initialize the Query Message, using given delegate as the carrier of payload and metadata and given queryName and expecting the given responseType.
      Parameters:
      delegate - The message containing the payload and meta data for this message
      queryName - The name identifying the query to execute
      responseType - The expected response type of type ResponseType
  • Method Details

    • getQueryName

      public String getQueryName()
      Description copied from interface: QueryMessage
      Returns the name identifying the query to be executed.
      Specified by:
      getQueryName in interface QueryMessage<T,R>
      Returns:
      the name identifying the query to be executed.
    • getResponseType

      public ResponseType<R> getResponseType()
      Description copied from interface: QueryMessage
      The type of response expected by the sender of the query
      Specified by:
      getResponseType in interface QueryMessage<T,R>
      Returns:
      the type of response expected by the sender of the query
    • withMetaData

      public QueryMessage<T,R> withMetaData(@Nonnull Map<String,?> metaData)
      Description copied from interface: QueryMessage
      Returns a copy of this QueryMessage with the given metaData. The payload remains unchanged.
      Specified by:
      withMetaData in interface Message<T>
      Specified by:
      withMetaData in interface QueryMessage<T,R>
      Parameters:
      metaData - The new MetaData for the QueryMessage
      Returns:
      a copy of this message with the given MetaData
    • andMetaData

      public QueryMessage<T,R> andMetaData(@Nonnull Map<String,?> metaData)
      Description copied from interface: QueryMessage
      Returns a copy of this QueryMessage with its MetaData merged with given metaData. The payload remains unchanged.
      Specified by:
      andMetaData in interface Message<T>
      Specified by:
      andMetaData in interface QueryMessage<T,R>
      Parameters:
      metaData - The MetaData to merge into the QueryMessage
      Returns:
      a copy of this message with the given additional MetaData
    • 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<T>
      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<T>
      Returns:
      the type of message