Record Class CommandDispatchReply
java.lang.Object
java.lang.Record
io.axoniq.framework.springcloud.command.CommandDispatchReply
- Record Components:
identifier- the identifier of this reply messagerequestIdentifier- theidentifierof the command this replies totype- thestring formof the result'stype, ornullwhen there is no result.payload- the result's payload as its converter wrote it, ornullwhen there is none.metadata- themetadataof the resulterrorCode- the kind of failure that occurred, ornullwhen handling succeedederrorMessage- a description of the failure, ornullwhen handling succeedederrorDetails- 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, ornullwhen handling succeedederrorDetailsType- the runtime class name of the application-specific details carried by the failure, ornullwhen 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, ornullwhen 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 result, with
type()and possiblypayload()set anderrorCode()null; - no result at all — the handler returned nothing — with both
type()anderrorCode()null; - a failure, with
errorCode()set.
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 Summary
ConstructorsConstructorDescriptionCommandDispatchReply(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 defaultingnullmetadata and error details to empty so a reply from a member that omits either field still reads. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static CommandDispatchReplyerror(String identifier, String requestIdentifier, CommandErrorCode errorCode, @Nullable String errorMessage, @Nullable String errorOrigin, List<String> errorDetails, @Nullable String errorDetailsType, @Nullable String errorDetailsPayload) Constructs aCommandDispatchReplyreporting that handling the command failed.@Nullable CommandErrorCodeReturns the value of theerrorCoderecord component.Returns the value of theerrorDetailsrecord component.@Nullable StringReturns the value of theerrorDetailsPayloadrecord component.@Nullable StringReturns the value of theerrorDetailsTyperecord component.@Nullable StringReturns the value of theerrorMessagerecord component.@Nullable StringReturns the value of theerrorOriginrecord component.booleanhasError()Indicates whether this reply reports a failure.final inthashCode()Returns a hash code value for this object.Returns the value of theidentifierrecord component.metadata()Returns the value of themetadatarecord component.static CommandDispatchReplyConstructs aCommandDispatchReplyreporting that the handler produced no result at all.@Nullable Stringpayload()Returns the value of thepayloadrecord component.Returns the value of therequestIdentifierrecord component.static CommandDispatchReplyresult(String identifier, String requestIdentifier, @Nullable String type, @Nullable String payload, Map<String, @Nullable String> metadata) Constructs aCommandDispatchReplycarrying the successful outcome of a command.final StringtoString()Returns a string representation of this record class.@Nullable Stringtype()Returns the value of thetyperecord component.
-
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 defaultingnullmetadata and error details to empty so a reply from a member that omits either field still reads.- Parameters:
identifier- the identifier of this reply messagerequestIdentifier- theidentifierof the command this replies totype- thestring formofpayload- the payload of the result as text, ornullmetadata- themetadataof the resulterrorCode- the kind of failure that occurred, ornullwhen handling succeedederrorMessage- a description of the failure, ornullwhen handling succeedederrorDetails- 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, ornullwhen handling succeedederrorDetailsType- the runtime class name of the application-specific details carried by the failure, orerrorDetailsPayload- 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 aCommandDispatchReplycarrying the successful outcome of a command.- Parameters:
identifier- the identifier of the resultrequestIdentifier- the identifier of the command this is a reply totype- thestring formof the result's type, ornullwhen the handler produced no resultpayload- the payload of the result as text, ornullwhen there is nonemetadata- the metadata of the result- Returns:
- a reply carrying the successful outcome of a command
-
noResult
Constructs aCommandDispatchReplyreporting that the handler produced no result at all.- Parameters:
identifier- the identifier of the replyrequestIdentifier- 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 aCommandDispatchReplyreporting that handling the command failed.- Parameters:
identifier- the identifier of the replyrequestIdentifier- the identifier of the command this is a reply toerrorCode- the kind of failure being reportederrorMessage- the message describing the failureerrorOrigin- the name of the member reporting the failureerrorDetails- the descriptions making up the failure's cause chainerrorDetailsType- the class name of the application-specific details, ornullwhen there are noneerrorDetailsPayload- the Base64-encoded application-specific details, ornullwhen 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 fromerrorCode()rather than a field of the wire format, and a bean-style name would have a serialization library write it as one.- Returns:
truewhen handling the command failed,falsewhen it succeeded
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
identifier
Returns the value of theidentifierrecord component.- Returns:
- the value of the
identifierrecord component
-
requestIdentifier
Returns the value of therequestIdentifierrecord component.- Returns:
- the value of the
requestIdentifierrecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
payload
Returns the value of thepayloadrecord component.- Returns:
- the value of the
payloadrecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-
errorCode
Returns the value of theerrorCoderecord component.- Returns:
- the value of the
errorCoderecord component
-
errorMessage
Returns the value of theerrorMessagerecord component.- Returns:
- the value of the
errorMessagerecord component
-
errorDetails
Returns the value of theerrorDetailsrecord component.- Returns:
- the value of the
errorDetailsrecord component
-
errorOrigin
Returns the value of theerrorOriginrecord component.- Returns:
- the value of the
errorOriginrecord component
-
errorDetailsType
Returns the value of theerrorDetailsTyperecord component.- Returns:
- the value of the
errorDetailsTyperecord component
-
errorDetailsPayload
Returns the value of theerrorDetailsPayloadrecord component.- Returns:
- the value of the
errorDetailsPayloadrecord component
-