R
- The type of payload contained in this Messagepublic interface ResultMessage<R> extends Message<R>
Modifier and Type | Method and Description |
---|---|
ResultMessage<R> |
andMetaData(Map<String,?> metaData)
Returns a copy of this Message with it MetaData merged with the given
metaData . |
default <D> Optional<D> |
exceptionDetails()
If the this message contains an exception result, returns the details provided in the exception, if available.
|
default Throwable |
exceptionResult()
Returns the exception result.
|
boolean |
isExceptional()
Indicates whether the ResultMessage represents unsuccessful execution.
|
Optional<Throwable> |
optionalExceptionResult()
Returns the Exception in case of exceptional result message or an empty
Optional in case of successful
execution. |
default <T> SerializedObject<T> |
serializeExceptionResult(Serializer serializer,
Class<T> expectedRepresentation)
Serializes the exception result.
|
default <S> SerializedObject<S> |
serializePayload(Serializer serializer,
Class<S> expectedRepresentation)
Serialize the payload of this message to the
expectedRepresentation using given serializer . |
ResultMessage<R> |
withMetaData(Map<String,?> metaData)
Returns a copy of this Message with the given
metaData . |
getIdentifier, getMetaData, getPayload, getPayloadType, serializeMetaData
boolean isExceptional()
true
if execution was unsuccessful, false
otherwiseOptional<Throwable> optionalExceptionResult()
Optional
in case of successful
execution.Optional
containing exception result or an empty Optional in case of a successful executiondefault Throwable exceptionResult() throws IllegalStateException
isExceptional()
returns true
.Throwable
defining the exception resultIllegalStateException
- if this ResultMessage is not exceptionaldefault <D> Optional<D> exceptionDetails()
D
- The type of application-specific details expecteddefault <S> SerializedObject<S> serializePayload(Serializer serializer, Class<S> expectedRepresentation)
Message
expectedRepresentation
using given serializer
. This
method should return the same SerializedObject instance when invoked multiple times using the same
serializer.serializePayload
in interface Message<R>
S
- The type of the serialized dataserializer
- The serializer to serialize payload withexpectedRepresentation
- The type of data to serialize todefault <T> SerializedObject<T> serializeExceptionResult(Serializer serializer, Class<T> expectedRepresentation)
RemoteExceptionDescription
from the Optional
exception in this ResultMessage instead of serializing the original exception.T
- the generic type representing the expected formatserializer
- the Serializer
used to serialize the exceptionexpectedRepresentation
- a Class
representing the expected formatSerializedObject
ResultMessage<R> withMetaData(@Nonnull Map<String,?> metaData)
Message
metaData
. The payload remains unchanged.
While the implementation returned may be different than the implementation of this
, implementations must
take special care in returning the same type of Message (e.g. EventMessage, DomainEventMessage) to prevent errors
further downstream.withMetaData
in interface Message<R>
metaData
- The new MetaData for the MessageResultMessage<R> andMetaData(@Nonnull Map<String,?> metaData)
Message
metaData
. The payload remains
unchanged.andMetaData
in interface Message<R>
metaData
- The MetaData to merge withCopyright © 2010–2024. All rights reserved.