public class ErrorMessage extends GenericMessage<java.lang.Throwable>
GenericMessage
with a Throwable
payload.
The payload is typically a MessagingException
with the message at the point of failure in its failedMessage
property.
An optional originalMessage
may be provided, which represents the message
that existed at the point in the stack where the error message is created.
Consider some code that starts with a message, invokes some process that performs transformation on that message and then fails for some reason, throwing the exception. The exception is caught and an error message produced that contains both the original message, and the transformed message that failed.
MessageBuilder
,
Serialized FormConstructor and Description |
---|
ErrorMessage(java.lang.Throwable payload)
Create a new message with the given payload.
|
ErrorMessage(java.lang.Throwable payload,
java.util.Map<java.lang.String,java.lang.Object> headers)
Create a new message with the given payload and headers.
|
ErrorMessage(java.lang.Throwable payload,
java.util.Map<java.lang.String,java.lang.Object> headers,
Message<?> originalMessage)
Create a new message with the given payload, headers and original message.
|
ErrorMessage(java.lang.Throwable payload,
Message<?> originalMessage)
Create a new message with the given payload and original message.
|
ErrorMessage(java.lang.Throwable payload,
MessageHeaders headers)
A constructor with the
MessageHeaders instance to use. |
ErrorMessage(java.lang.Throwable payload,
MessageHeaders headers,
Message<?> originalMessage)
Create a new message with the payload,
MessageHeaders and original message. |
Modifier and Type | Method and Description |
---|---|
Message<?> |
getOriginalMessage()
Return the original message (if available) at the point in the stack
where the ErrorMessage was created.
|
java.lang.String |
toString() |
equals, getHeaders, getPayload, hashCode
public ErrorMessage(java.lang.Throwable payload)
payload
- the message payload (never null
)public ErrorMessage(java.lang.Throwable payload, java.util.Map<java.lang.String,java.lang.Object> headers)
payload
- the message payload (never null
)headers
- message headers to use for initializationpublic ErrorMessage(java.lang.Throwable payload, MessageHeaders headers)
MessageHeaders
instance to use.
Note: the given MessageHeaders
instance
is used directly in the new message, i.e. it is not copied.
payload
- the message payload (never null
)headers
- message headerspublic ErrorMessage(java.lang.Throwable payload, Message<?> originalMessage)
payload
- the message payload (never null
)originalMessage
- the original message (if present) at the point
in the stack where the ErrorMessage was createdpublic ErrorMessage(java.lang.Throwable payload, java.util.Map<java.lang.String,java.lang.Object> headers, Message<?> originalMessage)
payload
- the message payload (never null
)headers
- message headers to use for initializationoriginalMessage
- the original message (if present) at the point
in the stack where the ErrorMessage was createdpublic ErrorMessage(java.lang.Throwable payload, MessageHeaders headers, Message<?> originalMessage)
MessageHeaders
and original message.
Note: the given MessageHeaders
instance
is used directly in the new message, i.e. it is not copied.
payload
- the message payload (never null
)headers
- message headersoriginalMessage
- the original message (if present) at the point
in the stack where the ErrorMessage was created@Nullable public Message<?> getOriginalMessage()
public java.lang.String toString()
toString
in class GenericMessage<java.lang.Throwable>