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 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.
|
ResultMessage<R> |
withMetaData(Map<String,?> metaData)
Returns a copy of this Message with the given
metaData . |
getIdentifier, getMetaData, getPayload, getPayloadType, serializeMetaData, serializePayload
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 <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(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(Map<String,?> metaData)
Message
metaData
. The payload
remains unchanged.andMetaData
in interface Message<R>
metaData
- The MetaData to merge withCopyright © 2010–2018. All rights reserved.