Record Class CommandDispatchReply

java.lang.Object
java.lang.Record
io.axoniq.framework.springcloud.command.CommandDispatchReply
Record Components:
identifier - the identifier of this reply message
requestIdentifier - the identifier of the command this replies to
type - the string form of the result's type, or null when there is no result.
payload - the result's payload as its converter wrote it, or null when there is none.
metadata - the metadata of the result
errorCode - the kind of failure that occurred, or null when handling succeeded
errorMessage - a description of the failure, or null when handling succeeded
errorDetails - the messages found down the failure's cause chain, outermost first, for diagnostics. Empty when handling succeeded.
errorOrigin - the name of the member the failure originated on, or null when handling succeeded
errorDetailsType - the runtime class name of the application-specific details carried by the failure, or null when it carries none. Present for wire-level observability only; the receiving member reconstructs details as the type its own code asks for.
errorDetailsPayload - the Base64-encoded serialized application-specific details carried by the failure, or null when it carries none

public record CommandDispatchReply(String identifier, String requestIdentifier, @Nullable String type, @Nullable String payload, Map<String,@Nullable String> metadata, @Nullable CommandErrorCode errorCode, @Nullable String errorMessage, List<String> errorDetails, @Nullable String errorOrigin, @Nullable String errorDetailsType, @Nullable String errorDetailsPayload) extends Record
The wire representation of the outcome of handling a command on another member of the cluster.

A reply carries exactly one of three outcomes, distinguished without ambiguity:

A failure is reported as a 200 OK response carrying this reply, not as an HTTP error status. The command was delivered and handled; that its handler threw is an application outcome, and conflating it with a transport failure would lose the distinction the dispatching member needs to decide whether retrying can help.
Since:
5.4.0
Author:
Allard Buijze
  • Constructor Details

    • CommandDispatchReply

      public CommandDispatchReply(String identifier, String requestIdentifier, @Nullable String type, @Nullable String payload, Map<String,@Nullable String> metadata, @Nullable CommandErrorCode errorCode, @Nullable String errorMessage, List<String> errorDetails, @Nullable String errorOrigin, @Nullable String errorDetailsType, @Nullable String errorDetailsPayload)
      Compact constructor requiring both identifiers, and defaulting null metadata and error details to empty so a reply from a member that omits either field still reads.
      Parameters:
      identifier - the identifier of this reply message
      requestIdentifier - the identifier of the command this replies to
      type - the string form of
      payload - the payload of the result as text, or null
      metadata - the metadata of the result
      errorCode - the kind of failure that occurred, or null when handling succeeded
      errorMessage - a description of the failure, or null when handling succeeded
      errorDetails - the messages found down the failure's cause chain, outermost first, for diagnostics. Empty when handling succeeded.
      errorOrigin - the name of the member the failure originated on, or null when handling succeeded
      errorDetailsType - the runtime class name of the application-specific details carried by the failure, or
      errorDetailsPayload - the Base64-encoded serialized application-specific details carried by the failure, or
  • Method Details

    • result

      public static CommandDispatchReply result(String identifier, String requestIdentifier, @Nullable String type, @Nullable String payload, Map<String,@Nullable String> metadata)
      Constructs a CommandDispatchReply carrying the successful outcome of a command.
      Parameters:
      identifier - the identifier of the result
      requestIdentifier - the identifier of the command this is a reply to
      type - the string form of the result's type, or null when the handler produced no result
      payload - the payload of the result as text, or null when there is none
      metadata - the metadata of the result
      Returns:
      a reply carrying the successful outcome of a command
    • noResult

      public static CommandDispatchReply noResult(String identifier, String requestIdentifier)
      Constructs a CommandDispatchReply reporting that the handler produced no result at all.
      Parameters:
      identifier - the identifier of the reply
      requestIdentifier - the identifier of the command this is a reply to
      Returns:
      a reply reporting that the handler produced no result
    • error

      public static CommandDispatchReply error(String identifier, String requestIdentifier, CommandErrorCode errorCode, @Nullable String errorMessage, @Nullable String errorOrigin, List<String> errorDetails, @Nullable String errorDetailsType, @Nullable String errorDetailsPayload)
      Constructs a CommandDispatchReply reporting that handling the command failed.
      Parameters:
      identifier - the identifier of the reply
      requestIdentifier - the identifier of the command this is a reply to
      errorCode - the kind of failure being reported
      errorMessage - the message describing the failure
      errorOrigin - the name of the member reporting the failure
      errorDetails - the descriptions making up the failure's cause chain
      errorDetailsType - the class name of the application-specific details, or null when there are none
      errorDetailsPayload - the Base64-encoded application-specific details, or null when there are none
      Returns:
      a reply reporting that handling the command failed
    • hasError

      public boolean hasError()
      Indicates whether this reply reports a failure.

      Deliberately not named isError: this is derived from errorCode() rather than a field of the wire format, and a bean-style name would have a serialization library write it as one.

      Returns:
      true when handling the command failed, false when it succeeded
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • identifier

      public String identifier()
      Returns the value of the identifier record component.
      Returns:
      the value of the identifier record component
    • requestIdentifier

      public String requestIdentifier()
      Returns the value of the requestIdentifier record component.
      Returns:
      the value of the requestIdentifier record component
    • type

      public @Nullable String type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • payload

      public @Nullable String payload()
      Returns the value of the payload record component.
      Returns:
      the value of the payload record component
    • metadata

      public Map<String,@Nullable String> metadata()
      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component
    • errorCode

      public @Nullable CommandErrorCode errorCode()
      Returns the value of the errorCode record component.
      Returns:
      the value of the errorCode record component
    • errorMessage

      public @Nullable String errorMessage()
      Returns the value of the errorMessage record component.
      Returns:
      the value of the errorMessage record component
    • errorDetails

      public List<String> errorDetails()
      Returns the value of the errorDetails record component.
      Returns:
      the value of the errorDetails record component
    • errorOrigin

      public @Nullable String errorOrigin()
      Returns the value of the errorOrigin record component.
      Returns:
      the value of the errorOrigin record component
    • errorDetailsType

      public @Nullable String errorDetailsType()
      Returns the value of the errorDetailsType record component.
      Returns:
      the value of the errorDetailsType record component
    • errorDetailsPayload

      public @Nullable String errorDetailsPayload()
      Returns the value of the errorDetailsPayload record component.
      Returns:
      the value of the errorDetailsPayload record component