public final class MessageHelper extends Object
Message
.Modifier and Type | Method and Description |
---|---|
static void |
copyHeaders(Message source,
Message target,
boolean override)
Copies the headers from the source to the target message.
|
static String |
doDumpMessageHistoryStacktrace(Exchange exchange,
ExchangeFormatter exchangeFormatter,
boolean logStackTrace) |
static String |
dumpAsXml(Message message)
Dumps the message as a generic XML structure.
|
static String |
dumpAsXml(Message message,
boolean includeBody)
Dumps the message as a generic XML structure.
|
static String |
dumpAsXml(Message message,
boolean includeBody,
int indent)
Dumps the message as a generic XML structure.
|
static String |
dumpAsXml(Message message,
boolean includeBody,
int indent,
boolean allowStreams,
boolean allowFiles,
int maxChars)
Dumps the message as a generic XML structure.
|
static String |
dumpMessageHistoryStacktrace(Exchange exchange,
ExchangeFormatter exchangeFormatter,
boolean logStackTrace)
Dumps the
MessageHistory from the Exchange in a human readable format. |
static String |
extractBodyAsString(Message message)
Extracts the given body and returns it as a String, that can be used for
logging etc.
|
static String |
extractBodyForLogging(Message message)
Extracts the body for logging purpose.
|
static String |
extractBodyForLogging(Message message,
String prepend)
Extracts the body for logging purpose.
|
static String |
extractBodyForLogging(Message message,
String prepend,
boolean allowStreams,
boolean allowFiles,
int maxChars)
Extracts the body for logging purpose.
|
static String |
extractValueForLogging(Object value,
Message message)
Extracts the value for logging purpose.
|
static String |
extractValueForLogging(Object obj,
Message message,
String prepend,
boolean allowStreams,
boolean allowFiles,
int maxChars)
Extracts the value for logging purpose.
|
static String |
getBodyTypeName(Message message)
Gets the given body class type name as a String.
|
static String |
getContentEncoding(Message message)
Returns the MIME content encoding on the message or null if none
defined
|
static String |
getContentType(Message message)
Returns the MIME content type on the message or null if none
defined
|
static void |
resetStreamCache(Message message)
If the message body contains a
StreamCache instance, reset the
cache to enable reading from it again. |
public static String extractBodyAsString(Message message)
message
- the message with the bodypublic static String getBodyTypeName(Message message)
message
- the message with the bodypublic static void resetStreamCache(Message message)
StreamCache
instance, reset the
cache to enable reading from it again.message
- the message for which to reset the bodypublic static String getContentType(Message message)
public static String getContentEncoding(Message message)
public static String extractBodyForLogging(Message message)
message
- the messageExchange.LOG_DEBUG_BODY_STREAMS
,
Exchange.LOG_DEBUG_BODY_MAX_CHARS
public static String extractValueForLogging(Object value, Message message)
value
- the valuemessage
- the messageExchange.LOG_DEBUG_BODY_STREAMS
,
Exchange.LOG_DEBUG_BODY_MAX_CHARS
public static String extractBodyForLogging(Message message, String prepend)
message
- the messageprepend
- a message to prependExchange.LOG_DEBUG_BODY_STREAMS
,
Exchange.LOG_DEBUG_BODY_MAX_CHARS
public static String extractBodyForLogging(Message message, String prepend, boolean allowStreams, boolean allowFiles, int maxChars)
message
- the messageprepend
- a message to prependallowStreams
- whether or not streams is allowedallowFiles
- whether or not files is allowed (currently not in use)maxChars
- limit to maximum number of chars. Use 0 for not limit, and -1 for turning logging message body off.Exchange.LOG_DEBUG_BODY_MAX_CHARS
public static String extractValueForLogging(Object obj, Message message, String prepend, boolean allowStreams, boolean allowFiles, int maxChars)
obj
- the valuemessage
- the messageprepend
- a message to prependallowStreams
- whether or not streams is allowedallowFiles
- whether or not files is allowed (currently not in use)maxChars
- limit to maximum number of chars. Use 0 for not limit, and -1 for turning logging message body off.Exchange.LOG_DEBUG_BODY_MAX_CHARS
public static String dumpAsXml(Message message)
message
- the messagepublic static String dumpAsXml(Message message, boolean includeBody)
message
- the messageincludeBody
- whether or not to include the message bodypublic static String dumpAsXml(Message message, boolean includeBody, int indent)
message
- the messageincludeBody
- whether or not to include the message bodyindent
- number of spaces to indentpublic static String dumpAsXml(Message message, boolean includeBody, int indent, boolean allowStreams, boolean allowFiles, int maxChars)
message
- the messageincludeBody
- whether or not to include the message bodyindent
- number of spaces to indentallowStreams
- whether to include message body if they are stream basedallowFiles
- whether to include message body if they are file basedmaxChars
- clip body after maximum chars (to avoid very big messages). Use 0 or negative value to not limit at all.public static void copyHeaders(Message source, Message target, boolean override)
source
- the source messagetarget
- the target messageoverride
- whether to override existing headerspublic static String dumpMessageHistoryStacktrace(Exchange exchange, ExchangeFormatter exchangeFormatter, boolean logStackTrace)
MessageHistory
from the Exchange
in a human readable format.exchange
- the exchangeexchangeFormatter
- if provided then information about the exchange is included in the dumplogStackTrace
- whether to include a header for the stacktrace, to be added (not included in this dump).public static String doDumpMessageHistoryStacktrace(Exchange exchange, ExchangeFormatter exchangeFormatter, boolean logStackTrace)
Apache Camel