Package org.apache.camel.support
Class DefaultMessage
- java.lang.Object
-
- org.apache.camel.support.MessageSupport
-
- org.apache.camel.support.DefaultMessage
-
- All Implemented Interfaces:
org.apache.camel.CamelContextAware
,org.apache.camel.Message
,org.apache.camel.spi.DataTypeAware
public class DefaultMessage extends MessageSupport
The default implementation ofMessage
This implementation uses aCaseInsensitiveMap
storing the headers. This allows us to be able to lookup headers using case insensitive keys, making it easier for end users as they do not have to be worried about using exact keys. See more details atCaseInsensitiveMap
. The implementation of the map can be configured by theHeadersMapFactory
which can be set on theCamelContext
. The default implementation uses theCaseInsensitiveMap
.
-
-
Constructor Summary
Constructors Constructor Description DefaultMessage(org.apache.camel.CamelContext camelContext)
DefaultMessage(org.apache.camel.Exchange exchange)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,Object>
createHeaders()
A factory method to lazily create the headers to make it easy to create efficient Message implementations which only construct and populate the Map on demandObject
getHeader(String name)
<T> T
getHeader(String name, Class<T> type)
Object
getHeader(String name, Object defaultValue)
<T> T
getHeader(String name, Object defaultValue, Class<T> type)
Object
getHeader(String name, Supplier<Object> defaultValueSupplier)
<T> T
getHeader(String name, Supplier<Object> defaultValueSupplier, Class<T> type)
Map<String,Object>
getHeaders()
boolean
hasHeaders()
protected boolean
hasPopulatedHeaders()
Returns true if the headers have been mutated in some wayprotected Boolean
isTransactedRedelivered()
A strategy for component specific messages to determine whether the message is redelivered or not.DefaultMessage
newInstance()
Returns a new instanceprotected void
populateInitialHeaders(Map<String,Object> map)
A strategy method populate the initial set of headers on an inbound message from an underlying bindingObject
removeHeader(String name)
boolean
removeHeaders(String pattern)
boolean
removeHeaders(String pattern, String... excludePatterns)
void
reset()
void
setHeader(String name, Object value)
void
setHeaders(Map<String,Object> headers)
-
Methods inherited from class org.apache.camel.support.MessageSupport
copy, copyFrom, copyFromWithNewBody, createBody, createMessageId, getBody, getBody, getBody, getCamelContext, getDataType, getExchange, getMandatoryBody, getMandatoryBody, getMessageId, getMessageTimestamp, hasDataType, hasMessageId, setBody, setBody, setBody, setCamelContext, setDataType, setExchange, setMessageId, toString
-
-
-
-
Method Detail
-
reset
public void reset()
- Specified by:
reset
in interfaceorg.apache.camel.Message
- Overrides:
reset
in classMessageSupport
-
getHeader
public <T> T getHeader(String name, Supplier<Object> defaultValueSupplier, Class<T> type)
-
removeHeaders
public boolean removeHeaders(String pattern)
-
hasHeaders
public boolean hasHeaders()
-
newInstance
public DefaultMessage newInstance()
Description copied from class:MessageSupport
Returns a new instance- Specified by:
newInstance
in classMessageSupport
-
createHeaders
protected Map<String,Object> createHeaders()
A factory method to lazily create the headers to make it easy to create efficient Message implementations which only construct and populate the Map on demand- Returns:
- return a newly constructed Map possibly containing headers from the underlying inbound transport
-
populateInitialHeaders
protected void populateInitialHeaders(Map<String,Object> map)
A strategy method populate the initial set of headers on an inbound message from an underlying binding- Parameters:
map
- is the empty header map to populate
-
isTransactedRedelivered
protected Boolean isTransactedRedelivered()
A strategy for component specific messages to determine whether the message is redelivered or not. Important: It is not always possible to determine if the transacted is a redelivery or not, and therefore null is returned. Such an example would be a JDBC message. However JMS brokers provides details if a transacted message is redelivered.- Returns:
- true if redelivered, false if not, null if not able to determine
-
hasPopulatedHeaders
protected boolean hasPopulatedHeaders()
Returns true if the headers have been mutated in some way
-
-