Package org.apache.camel
Interface Exchange
-
- All Known Subinterfaces:
ExtendedExchange
,PooledExchange
@ConstantProvider("org.apache.camel.ExchangeConstantProvider") public interface Exchange
An Exchange is the message container holding the information during the entire routing of aMessage
received by aConsumer
. During processing down theProcessor
chain, theExchange
provides access to the current (not the original) request and responseMessage
messages. TheExchange
also holds meta-data during its entire lifetime stored as properties accessible using the variousgetProperty(String)
methods. ThesetProperty(String, Object)
is used to store a property. For example you can use this to store security, SLA related data or any other information deemed useful throughout processing. If anExchange
failed during routing theException
that caused the failure is stored and accessible via thegetException()
method. An Exchange is created when aConsumer
receives a request. A newMessage
is created, the request is set as the body of theMessage
and depending on theConsumer
otherEndpoint
and protocol related information is added as headers on theMessage
. Then an Exchange is created and the newly createdMessage
is set as the in on the Exchange. Therefore an Exchange starts its life in aConsumer
. The Exchange is then sent down theRoute
for processing along aProcessor
chain. TheProcessor
as the name suggests is what processes theMessage
in the Exchange and Camel, in addition to providing out-of-the-box a large number of useful processors, it also allows you to create your own. The rule Camel uses is to take the outMessage
produced by the previousProcessor
and set it as the in for the nextProcessor
. If the previousProcessor
did not produce an out, then the in of the previousProcessor
is sent as the next in. At the end of the processing chain, depending on theMessage Exchange Pattern
(or MEP) the last out (or in of no out available) is sent by theConsumer
back to the original caller. Camel, in addition to providing out-of-the-box a large number of useful processors, it also allows you to implement and use your own. When the Exchange is passed to aProcessor
, it always contains an inMessage
and no outMessage
. TheProcessor
may produce an out, depending on the nature of theProcessor
. The inMessage
can be accessed using thegetIn()
method. Since the out message is null when entering theProcessor
, thegetOut()
method is actually a convenient factory method that will lazily instantiate aorg.apache.camel.support.DefaultMessage
which you could populate. As an alternative you could also instantiate your specializedMessage
and set it on the exchange using thesetOut(org.apache.camel.Message)
method. Please note that aMessage
contains not only the body but also headers and attachments. If you are creating a newMessage
the headers and attachments of the inMessage
are not automatically copied to the out by Camel and you'll have to set the headers and attachments you need yourself. If yourProcessor
is not producing a differentMessage
but only needs to slightly modify the in, you can simply update the inMessage
returned bygetIn()
. See this FAQ entry for more details.
-
-
Field Summary
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description <T extends Exchange>
Tadapt(Class<T> type)
Adapts thisExchange
to the specialized type.Exchange
copy()
Creates a copy of the current message exchange so that it can be forwarded to another destinationMap<String,Object>
getAllProperties()
Returns all (both internal and custom) properties associated with the exchangeCamelContext
getContext()
Returns the container so that a processor can resolve endpoints from URIslong
getCreated()
Gets the timestamp in millis when this exchange was created.Exception
getException()
Returns the exception associated with this exchange<T> T
getException(Class<T> type)
Returns the exception associated with this exchange.String
getExchangeId()
Returns the exchange id (unique)Endpoint
getFromEndpoint()
Returns the endpoint which originated this message exchange if a consumer on an endpoint created the message exchange, otherwise his property will be null.String
getFromRouteId()
Returns the route id which originated this message exchange if a route consumer on an endpoint created the message exchange, otherwise his property will be null.Message
getIn()
Returns the inbound request message<T> T
getIn(Class<T> type)
Returns the inbound request message as the given typeMessage
getMessage()
Returns the current message<T> T
getMessage(Class<T> type)
Returns the current message as the given typeMessage
getOut()
Deprecated.usegetMessage()
<T> T
getOut(Class<T> type)
Deprecated.ExchangePattern
getPattern()
Returns theExchangePattern
(MEP) of this exchange.Map<String,Object>
getProperties()
Returns the properties associated with the exchangeObject
getProperty(String name)
Returns a property associated with this exchange by name<T> T
getProperty(String name, Class<T> type)
Returns a property associated with this exchange by name and specifying the type requiredObject
getProperty(String name, Object defaultValue)
Deprecated.<T> T
getProperty(String name, Object defaultValue, Class<T> type)
Returns a property associated with this exchange by name and specifying the type requiredObject
getProperty(ExchangePropertyKey key)
Returns a property associated with this exchange by the key<T> T
getProperty(ExchangePropertyKey key, Class<T> type)
Returns a property associated with this exchange by the key and specifying the type required<T> T
getProperty(ExchangePropertyKey key, Object defaultValue, Class<T> type)
Returns a property associated with this exchange by name and specifying the type requiredUnitOfWork
getUnitOfWork()
Returns the unit of work that this exchange belongs to; which may map to zero, one or more physical transactionsboolean
hasOut()
Deprecated.usegetMessage()
boolean
hasProperties()
Returns whether any properties has been setboolean
isExternalRedelivered()
Returns true if this exchange is an external initiated redelivered message (such as a JMS broker).boolean
isFailed()
Returns true if this exchange failed due to an exceptionboolean
isRollbackOnly()
Returns true if this exchange is marked for rollbackboolean
isRollbackOnlyLast()
Returns true if this exchange is marked for rollback (only last transaction section)boolean
isRouteStop()
Returns true if this exchange is marked to stop and not continue routing.boolean
isTransacted()
Returns true if this exchange is transactedboolean
removeProperties(String pattern)
Remove all the properties associated with the exchange matching a specific patternboolean
removeProperties(String pattern, String... excludePatterns)
Removes the properties from this exchange that match the given pattern, except for the ones matching one or more excludePatternsObject
removeProperty(String name)
Removes the given property on the exchangeObject
removeProperty(ExchangePropertyKey key)
Removes the given property on the exchangevoid
setException(Throwable t)
Sets the exception associated with this exchangevoid
setExchangeId(String id)
Set the exchange idvoid
setIn(Message in)
Sets the inbound message instancevoid
setMessage(Message message)
Replace the current message instance.void
setOut(Message out)
Deprecated.void
setPattern(ExchangePattern pattern)
Allows theExchangePattern
(MEP) of this exchange to be customized.void
setProperty(String name, Object value)
Sets a property on the exchangevoid
setProperty(ExchangePropertyKey key, Object value)
Sets a property on the exchangevoid
setRollbackOnly(boolean rollbackOnly)
Sets whether to mark this exchange for rollbackvoid
setRollbackOnlyLast(boolean rollbackOnlyLast)
Sets whether to mark this exchange for rollback (only last transaction section)void
setRouteStop(boolean routeStop)
Sets whether this exchange is marked to stop and not continue routing.
-
-
-
Field Detail
-
AUTHENTICATION
static final String AUTHENTICATION
- See Also:
- Constant Field Values
-
AUTHENTICATION_FAILURE_POLICY_ID
static final String AUTHENTICATION_FAILURE_POLICY_ID
- See Also:
- Constant Field Values
-
ACCEPT_CONTENT_TYPE
@Deprecated static final String ACCEPT_CONTENT_TYPE
Deprecated.- See Also:
- Constant Field Values
-
AGGREGATED_SIZE
static final String AGGREGATED_SIZE
- See Also:
- Constant Field Values
-
AGGREGATED_TIMEOUT
static final String AGGREGATED_TIMEOUT
- See Also:
- Constant Field Values
-
AGGREGATED_COMPLETED_BY
static final String AGGREGATED_COMPLETED_BY
- See Also:
- Constant Field Values
-
AGGREGATED_CORRELATION_KEY
static final String AGGREGATED_CORRELATION_KEY
- See Also:
- Constant Field Values
-
AGGREGATED_COLLECTION_GUARD
static final String AGGREGATED_COLLECTION_GUARD
- See Also:
- Constant Field Values
-
AGGREGATION_STRATEGY
static final String AGGREGATION_STRATEGY
- See Also:
- Constant Field Values
-
AGGREGATION_COMPLETE_CURRENT_GROUP
static final String AGGREGATION_COMPLETE_CURRENT_GROUP
- See Also:
- Constant Field Values
-
AGGREGATION_COMPLETE_ALL_GROUPS
static final String AGGREGATION_COMPLETE_ALL_GROUPS
- See Also:
- Constant Field Values
-
AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE
static final String AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE
- See Also:
- Constant Field Values
-
ASYNC_WAIT
static final String ASYNC_WAIT
- See Also:
- Constant Field Values
-
BATCH_INDEX
static final String BATCH_INDEX
- See Also:
- Constant Field Values
-
BATCH_SIZE
static final String BATCH_SIZE
- See Also:
- Constant Field Values
-
BATCH_COMPLETE
static final String BATCH_COMPLETE
- See Also:
- Constant Field Values
-
BEAN_METHOD_NAME
static final String BEAN_METHOD_NAME
- See Also:
- Constant Field Values
-
BINDING
static final String BINDING
- See Also:
- Constant Field Values
-
BREADCRUMB_ID
static final String BREADCRUMB_ID
- See Also:
- Constant Field Values
-
CHARSET_NAME
static final String CHARSET_NAME
- See Also:
- Constant Field Values
-
CIRCUIT_BREAKER_STATE
static final String CIRCUIT_BREAKER_STATE
- See Also:
- Constant Field Values
-
CREATED_TIMESTAMP
@Deprecated static final String CREATED_TIMESTAMP
Deprecated.- See Also:
- Constant Field Values
-
CLAIM_CHECK_REPOSITORY
static final String CLAIM_CHECK_REPOSITORY
- See Also:
- Constant Field Values
-
CONTENT_ENCODING
static final String CONTENT_ENCODING
- See Also:
- Constant Field Values
-
CONTENT_LENGTH
static final String CONTENT_LENGTH
- See Also:
- Constant Field Values
-
CONTENT_TYPE
static final String CONTENT_TYPE
- See Also:
- Constant Field Values
-
COOKIE_HANDLER
static final String COOKIE_HANDLER
- See Also:
- Constant Field Values
-
CORRELATION_ID
static final String CORRELATION_ID
- See Also:
- Constant Field Values
-
DATASET_INDEX
static final String DATASET_INDEX
- See Also:
- Constant Field Values
-
DEFAULT_CHARSET_PROPERTY
static final String DEFAULT_CHARSET_PROPERTY
- See Also:
- Constant Field Values
-
DESTINATION_OVERRIDE_URL
static final String DESTINATION_OVERRIDE_URL
- See Also:
- Constant Field Values
-
DISABLE_HTTP_STREAM_CACHE
static final String DISABLE_HTTP_STREAM_CACHE
- See Also:
- Constant Field Values
-
DUPLICATE_MESSAGE
static final String DUPLICATE_MESSAGE
- See Also:
- Constant Field Values
-
DOCUMENT_BUILDER_FACTORY
static final String DOCUMENT_BUILDER_FACTORY
- See Also:
- Constant Field Values
-
EXCEPTION_CAUGHT
static final String EXCEPTION_CAUGHT
- See Also:
- Constant Field Values
-
EXCEPTION_HANDLED
static final String EXCEPTION_HANDLED
- See Also:
- Constant Field Values
-
EVALUATE_EXPRESSION_RESULT
static final String EVALUATE_EXPRESSION_RESULT
- See Also:
- Constant Field Values
-
ERRORHANDLER_BRIDGE
static final String ERRORHANDLER_BRIDGE
- See Also:
- Constant Field Values
-
ERRORHANDLER_CIRCUIT_DETECTED
static final String ERRORHANDLER_CIRCUIT_DETECTED
- See Also:
- Constant Field Values
-
ERRORHANDLER_HANDLED
@Deprecated static final String ERRORHANDLER_HANDLED
Deprecated.- See Also:
- Constant Field Values
-
EXTERNAL_REDELIVERED
@Deprecated static final String EXTERNAL_REDELIVERED
Deprecated.- See Also:
- Constant Field Values
-
FAILURE_HANDLED
static final String FAILURE_HANDLED
- See Also:
- Constant Field Values
-
FAILURE_ENDPOINT
static final String FAILURE_ENDPOINT
- See Also:
- Constant Field Values
-
FAILURE_ROUTE_ID
static final String FAILURE_ROUTE_ID
- See Also:
- Constant Field Values
-
FATAL_FALLBACK_ERROR_HANDLER
static final String FATAL_FALLBACK_ERROR_HANDLER
- See Also:
- Constant Field Values
-
FILE_CONTENT_TYPE
static final String FILE_CONTENT_TYPE
- See Also:
- Constant Field Values
-
FILE_LOCAL_WORK_PATH
static final String FILE_LOCAL_WORK_PATH
- See Also:
- Constant Field Values
-
FILE_NAME
static final String FILE_NAME
- See Also:
- Constant Field Values
-
FILE_NAME_ONLY
static final String FILE_NAME_ONLY
- See Also:
- Constant Field Values
-
FILE_NAME_PRODUCED
static final String FILE_NAME_PRODUCED
- See Also:
- Constant Field Values
-
FILE_NAME_CONSUMED
static final String FILE_NAME_CONSUMED
- See Also:
- Constant Field Values
-
FILE_PATH
static final String FILE_PATH
- See Also:
- Constant Field Values
-
FILE_PARENT
static final String FILE_PARENT
- See Also:
- Constant Field Values
-
FILE_LAST_MODIFIED
static final String FILE_LAST_MODIFIED
- See Also:
- Constant Field Values
-
FILE_LENGTH
static final String FILE_LENGTH
- See Also:
- Constant Field Values
-
FILE_LOCK_FILE_ACQUIRED
static final String FILE_LOCK_FILE_ACQUIRED
- See Also:
- Constant Field Values
-
FILE_LOCK_FILE_NAME
static final String FILE_LOCK_FILE_NAME
- See Also:
- Constant Field Values
-
FILE_LOCK_EXCLUSIVE_LOCK
static final String FILE_LOCK_EXCLUSIVE_LOCK
- See Also:
- Constant Field Values
-
FILE_LOCK_RANDOM_ACCESS_FILE
static final String FILE_LOCK_RANDOM_ACCESS_FILE
- See Also:
- Constant Field Values
-
FILE_LOCK_CHANNEL_FILE
static final String FILE_LOCK_CHANNEL_FILE
- See Also:
- Constant Field Values
-
FILTER_MATCHED
@Deprecated static final String FILTER_MATCHED
Deprecated.- See Also:
- Constant Field Values
-
FILTER_NON_XML_CHARS
static final String FILTER_NON_XML_CHARS
- See Also:
- Constant Field Values
-
GROUPED_EXCHANGE
static final String GROUPED_EXCHANGE
- See Also:
- Constant Field Values
-
HTTP_SCHEME
static final String HTTP_SCHEME
- See Also:
- Constant Field Values
-
HTTP_HOST
static final String HTTP_HOST
- See Also:
- Constant Field Values
-
HTTP_PORT
static final String HTTP_PORT
- See Also:
- Constant Field Values
-
HTTP_BASE_URI
static final String HTTP_BASE_URI
- See Also:
- Constant Field Values
-
HTTP_CHARACTER_ENCODING
static final String HTTP_CHARACTER_ENCODING
- See Also:
- Constant Field Values
-
HTTP_METHOD
static final String HTTP_METHOD
- See Also:
- Constant Field Values
-
HTTP_PATH
static final String HTTP_PATH
- See Also:
- Constant Field Values
-
HTTP_PROTOCOL_VERSION
static final String HTTP_PROTOCOL_VERSION
- See Also:
- Constant Field Values
-
HTTP_QUERY
static final String HTTP_QUERY
- See Also:
- Constant Field Values
-
HTTP_RAW_QUERY
static final String HTTP_RAW_QUERY
- See Also:
- Constant Field Values
-
HTTP_RESPONSE_CODE
static final String HTTP_RESPONSE_CODE
- See Also:
- Constant Field Values
-
HTTP_RESPONSE_TEXT
static final String HTTP_RESPONSE_TEXT
- See Also:
- Constant Field Values
-
HTTP_URI
static final String HTTP_URI
- See Also:
- Constant Field Values
-
HTTP_URL
static final String HTTP_URL
- See Also:
- Constant Field Values
-
HTTP_CHUNKED
static final String HTTP_CHUNKED
- See Also:
- Constant Field Values
-
HTTP_SERVLET_REQUEST
static final String HTTP_SERVLET_REQUEST
- See Also:
- Constant Field Values
-
HTTP_SERVLET_RESPONSE
static final String HTTP_SERVLET_RESPONSE
- See Also:
- Constant Field Values
-
INTERCEPTED_ENDPOINT
static final String INTERCEPTED_ENDPOINT
- See Also:
- Constant Field Values
-
INTERCEPT_SEND_TO_ENDPOINT_WHEN_MATCHED
static final String INTERCEPT_SEND_TO_ENDPOINT_WHEN_MATCHED
- See Also:
- Constant Field Values
-
INTERRUPTED
@Deprecated static final String INTERRUPTED
Deprecated.- See Also:
- Constant Field Values
-
LANGUAGE_SCRIPT
static final String LANGUAGE_SCRIPT
- See Also:
- Constant Field Values
-
LOG_DEBUG_BODY_MAX_CHARS
static final String LOG_DEBUG_BODY_MAX_CHARS
- See Also:
- Constant Field Values
-
LOG_DEBUG_BODY_STREAMS
static final String LOG_DEBUG_BODY_STREAMS
- See Also:
- Constant Field Values
-
LOG_EIP_NAME
static final String LOG_EIP_NAME
- See Also:
- Constant Field Values
-
LOOP_INDEX
static final String LOOP_INDEX
- See Also:
- Constant Field Values
-
LOOP_SIZE
static final String LOOP_SIZE
- See Also:
- Constant Field Values
-
SAGA_LONG_RUNNING_ACTION
static final String SAGA_LONG_RUNNING_ACTION
- See Also:
- Constant Field Values
-
MAXIMUM_CACHE_POOL_SIZE
static final String MAXIMUM_CACHE_POOL_SIZE
- See Also:
- Constant Field Values
-
MAXIMUM_ENDPOINT_CACHE_SIZE
static final String MAXIMUM_ENDPOINT_CACHE_SIZE
- See Also:
- Constant Field Values
-
MAXIMUM_SIMPLE_CACHE_SIZE
static final String MAXIMUM_SIMPLE_CACHE_SIZE
- See Also:
- Constant Field Values
-
MAXIMUM_TRANSFORMER_CACHE_SIZE
static final String MAXIMUM_TRANSFORMER_CACHE_SIZE
- See Also:
- Constant Field Values
-
MAXIMUM_VALIDATOR_CACHE_SIZE
static final String MAXIMUM_VALIDATOR_CACHE_SIZE
- See Also:
- Constant Field Values
-
MESSAGE_HISTORY
static final String MESSAGE_HISTORY
- See Also:
- Constant Field Values
-
MESSAGE_HISTORY_HEADER_FORMAT
static final String MESSAGE_HISTORY_HEADER_FORMAT
- See Also:
- Constant Field Values
-
MESSAGE_HISTORY_OUTPUT_FORMAT
static final String MESSAGE_HISTORY_OUTPUT_FORMAT
- See Also:
- Constant Field Values
-
MESSAGE_TIMESTAMP
static final String MESSAGE_TIMESTAMP
- See Also:
- Constant Field Values
-
MULTICAST_INDEX
static final String MULTICAST_INDEX
- See Also:
- Constant Field Values
-
MULTICAST_COMPLETE
static final String MULTICAST_COMPLETE
- See Also:
- Constant Field Values
-
NOTIFY_EVENT
@Deprecated static final String NOTIFY_EVENT
Deprecated.- See Also:
- Constant Field Values
-
ON_COMPLETION
static final String ON_COMPLETION
- See Also:
- Constant Field Values
-
ON_COMPLETION_ROUTE_IDS
static final String ON_COMPLETION_ROUTE_IDS
- See Also:
- Constant Field Values
-
OVERRULE_FILE_NAME
static final String OVERRULE_FILE_NAME
- See Also:
- Constant Field Values
-
PARENT_UNIT_OF_WORK
static final String PARENT_UNIT_OF_WORK
- See Also:
- Constant Field Values
-
STREAM_CACHE_UNIT_OF_WORK
static final String STREAM_CACHE_UNIT_OF_WORK
- See Also:
- Constant Field Values
-
RECIPIENT_LIST_ENDPOINT
static final String RECIPIENT_LIST_ENDPOINT
- See Also:
- Constant Field Values
-
RECEIVED_TIMESTAMP
static final String RECEIVED_TIMESTAMP
- See Also:
- Constant Field Values
-
REDELIVERED
static final String REDELIVERED
- See Also:
- Constant Field Values
-
REDELIVERY_COUNTER
static final String REDELIVERY_COUNTER
- See Also:
- Constant Field Values
-
REDELIVERY_MAX_COUNTER
static final String REDELIVERY_MAX_COUNTER
- See Also:
- Constant Field Values
-
REDELIVERY_EXHAUSTED
@Deprecated static final String REDELIVERY_EXHAUSTED
Deprecated.- See Also:
- Constant Field Values
-
REDELIVERY_DELAY
static final String REDELIVERY_DELAY
- See Also:
- Constant Field Values
-
REST_HTTP_URI
static final String REST_HTTP_URI
- See Also:
- Constant Field Values
-
REST_HTTP_QUERY
static final String REST_HTTP_QUERY
- See Also:
- Constant Field Values
-
ROLLBACK_ONLY
@Deprecated static final String ROLLBACK_ONLY
Deprecated.- See Also:
- Constant Field Values
-
ROLLBACK_ONLY_LAST
@Deprecated static final String ROLLBACK_ONLY_LAST
Deprecated.- See Also:
- Constant Field Values
-
ROUTE_STOP
@Deprecated static final String ROUTE_STOP
Deprecated.- See Also:
- Constant Field Values
-
REUSE_SCRIPT_ENGINE
static final String REUSE_SCRIPT_ENGINE
- See Also:
- Constant Field Values
-
COMPILE_SCRIPT
static final String COMPILE_SCRIPT
- See Also:
- Constant Field Values
-
SAXPARSER_FACTORY
static final String SAXPARSER_FACTORY
- See Also:
- Constant Field Values
-
SCHEDULER_POLLED_MESSAGES
static final String SCHEDULER_POLLED_MESSAGES
- See Also:
- Constant Field Values
-
SOAP_ACTION
static final String SOAP_ACTION
- See Also:
- Constant Field Values
-
SKIP_GZIP_ENCODING
static final String SKIP_GZIP_ENCODING
- See Also:
- Constant Field Values
-
SKIP_WWW_FORM_URLENCODED
static final String SKIP_WWW_FORM_URLENCODED
- See Also:
- Constant Field Values
-
SLIP_ENDPOINT
static final String SLIP_ENDPOINT
- See Also:
- Constant Field Values
-
SLIP_PRODUCER
static final String SLIP_PRODUCER
- See Also:
- Constant Field Values
-
SPLIT_INDEX
static final String SPLIT_INDEX
- See Also:
- Constant Field Values
-
SPLIT_COMPLETE
static final String SPLIT_COMPLETE
- See Also:
- Constant Field Values
-
SPLIT_SIZE
static final String SPLIT_SIZE
- See Also:
- Constant Field Values
-
STEP_ID
static final String STEP_ID
- See Also:
- Constant Field Values
-
TIMER_COUNTER
static final String TIMER_COUNTER
- See Also:
- Constant Field Values
-
TIMER_FIRED_TIME
static final String TIMER_FIRED_TIME
- See Also:
- Constant Field Values
-
TIMER_NAME
static final String TIMER_NAME
- See Also:
- Constant Field Values
-
TIMER_PERIOD
static final String TIMER_PERIOD
- See Also:
- Constant Field Values
-
TIMER_TIME
static final String TIMER_TIME
- See Also:
- Constant Field Values
-
TO_ENDPOINT
static final String TO_ENDPOINT
- See Also:
- Constant Field Values
-
TRACE_EVENT
static final String TRACE_EVENT
- See Also:
- Constant Field Values
-
TRACE_EVENT_NODE_ID
static final String TRACE_EVENT_NODE_ID
- See Also:
- Constant Field Values
-
TRACE_EVENT_TIMESTAMP
static final String TRACE_EVENT_TIMESTAMP
- See Also:
- Constant Field Values
-
TRACE_EVENT_EXCHANGE
static final String TRACE_EVENT_EXCHANGE
- See Also:
- Constant Field Values
-
TRACING_HEADER_FORMAT
static final String TRACING_HEADER_FORMAT
- See Also:
- Constant Field Values
-
TRACING_OUTPUT_FORMAT
static final String TRACING_OUTPUT_FORMAT
- See Also:
- Constant Field Values
-
TRY_ROUTE_BLOCK
static final String TRY_ROUTE_BLOCK
- See Also:
- Constant Field Values
-
TRANSFER_ENCODING
static final String TRANSFER_ENCODING
- See Also:
- Constant Field Values
-
UNIT_OF_WORK_EXHAUSTED
static final String UNIT_OF_WORK_EXHAUSTED
- See Also:
- Constant Field Values
-
UNIT_OF_WORK_PROCESS_SYNC
@Deprecated static final String UNIT_OF_WORK_PROCESS_SYNC
Deprecated.UNIT_OF_WORK_PROCESS_SYNC is not in use and will be removed in future Camel release- See Also:
- Constant Field Values
-
XSLT_FILE_NAME
static final String XSLT_FILE_NAME
- See Also:
- Constant Field Values
-
XSLT_ERROR
static final String XSLT_ERROR
- See Also:
- Constant Field Values
-
XSLT_FATAL_ERROR
static final String XSLT_FATAL_ERROR
- See Also:
- Constant Field Values
-
XSLT_WARNING
static final String XSLT_WARNING
- See Also:
- Constant Field Values
-
-
Method Detail
-
adapt
<T extends Exchange> T adapt(Class<T> type)
Adapts thisExchange
to the specialized type. For example to adapt to ExtendedExchange.- Parameters:
type
- the type to adapt to- Returns:
- this
Exchange
adapted to the given type
-
getPattern
ExchangePattern getPattern()
Returns theExchangePattern
(MEP) of this exchange.- Returns:
- the message exchange pattern of this exchange
-
setPattern
void setPattern(ExchangePattern pattern)
Allows theExchangePattern
(MEP) of this exchange to be customized. This typically won't be required as an exchange can be created with a specific MEP by callingEndpoint.createExchange(ExchangePattern)
but it is here just in case it is needed.- Parameters:
pattern
- the pattern
-
getProperty
Object getProperty(ExchangePropertyKey key)
Returns a property associated with this exchange by the key- Parameters:
key
- the exchange key- Returns:
- the value of the given property or null if there is no property for the given key
-
getProperty
<T> T getProperty(ExchangePropertyKey key, Class<T> type)
Returns a property associated with this exchange by the key and specifying the type required- Parameters:
key
- the exchange keytype
- the type of the property- Returns:
- the value of the given property or null if there is no property for the given name or null if it cannot be converted to the given type
-
getProperty
<T> T getProperty(ExchangePropertyKey key, Object defaultValue, Class<T> type)
Returns a property associated with this exchange by name and specifying the type required- Parameters:
key
- the exchange keydefaultValue
- the default value to return if property was absenttype
- the type of the property- Returns:
- the value of the given property or defaultValue if there is no property for the given name or null if it cannot be converted to the given type
-
setProperty
void setProperty(ExchangePropertyKey key, Object value)
Sets a property on the exchange- Parameters:
key
- the exchange keyvalue
- to associate with the name
-
removeProperty
Object removeProperty(ExchangePropertyKey key)
Removes the given property on the exchange- Parameters:
key
- the exchange key- Returns:
- the old value of the property
-
getProperty
Object getProperty(String name)
Returns a property associated with this exchange by name- Parameters:
name
- the name of the property- Returns:
- the value of the given property or null if there is no property for the given name
-
getProperty
@Deprecated Object getProperty(String name, Object defaultValue)
Deprecated.Returns a property associated with this exchange by name- Parameters:
name
- the name of the propertydefaultValue
- the default value to return if property was absent- Returns:
- the value of the given property or defaultValue if there is no property for the given name
-
getProperty
<T> T getProperty(String name, Class<T> type)
Returns a property associated with this exchange by name and specifying the type required- Parameters:
name
- the name of the propertytype
- the type of the property- Returns:
- the value of the given property or null if there is no property for the given name or null if it cannot be converted to the given type
-
getProperty
<T> T getProperty(String name, Object defaultValue, Class<T> type)
Returns a property associated with this exchange by name and specifying the type required- Parameters:
name
- the name of the propertydefaultValue
- the default value to return if property was absenttype
- the type of the property- Returns:
- the value of the given property or defaultValue if there is no property for the given name or null if it cannot be converted to the given type
-
setProperty
void setProperty(String name, Object value)
Sets a property on the exchange- Parameters:
name
- of the propertyvalue
- to associate with the name
-
removeProperty
Object removeProperty(String name)
Removes the given property on the exchange- Parameters:
name
- of the property- Returns:
- the old value of the property
-
removeProperties
boolean removeProperties(String pattern)
Remove all the properties associated with the exchange matching a specific pattern- Parameters:
pattern
- pattern of names- Returns:
- boolean whether any properties matched
-
removeProperties
boolean removeProperties(String pattern, String... excludePatterns)
Removes the properties from this exchange that match the given pattern, except for the ones matching one or more excludePatterns- Parameters:
pattern
- pattern of names that should be removedexcludePatterns
- one or more pattern of properties names that should be excluded (= preserved)- Returns:
- boolean whether any properties matched
-
getProperties
Map<String,Object> getProperties()
Returns the properties associated with the exchange- Returns:
- the properties in a Map
- See Also:
getAllProperties()
-
getAllProperties
Map<String,Object> getAllProperties()
Returns all (both internal and custom) properties associated with the exchange- Returns:
- all (both internal and custom) properties in a Map
- See Also:
getProperties()
-
hasProperties
boolean hasProperties()
Returns whether any properties has been set- Returns:
- true if any properties has been set
-
getIn
Message getIn()
Returns the inbound request message- Returns:
- the message
-
getMessage
Message getMessage()
Returns the current message- Returns:
- the current message
-
getMessage
<T> T getMessage(Class<T> type)
Returns the current message as the given type- Parameters:
type
- the given type- Returns:
- the message as the given type or null if not possible to covert to given type
-
setMessage
void setMessage(Message message)
Replace the current message instance.- Parameters:
message
- the new message
-
getIn
<T> T getIn(Class<T> type)
Returns the inbound request message as the given type- Parameters:
type
- the given type- Returns:
- the message as the given type or null if not possible to covert to given type
-
setIn
void setIn(Message in)
Sets the inbound message instance- Parameters:
in
- the inbound message
-
getOut
@Deprecated Message getOut()
Deprecated.usegetMessage()
Returns the outbound message, lazily creating one if one has not already been associated with this exchange.
Important: If you want to change the current message, then usegetIn()
instead as it will ensure headers etc. is kept and propagated when routing continues. Bottom line end users should rarely use this method.
If you want to test whether an OUT message have been set or not, use thehasOut()
method. See also the class java doc for thisExchange
for more details and this FAQ entry.- Returns:
- the response
- See Also:
getIn()
-
getOut
@Deprecated <T> T getOut(Class<T> type)
Deprecated.Returns the outbound request message as the given type
Important: If you want to change the current message, then usegetIn()
instead as it will ensure headers etc. is kept and propagated when routing continues. Bottom line end users should rarely use this method.
If you want to test whether an OUT message have been set or not, use thehasOut()
method. See also the class java doc for thisExchange
for more details and this FAQ entry.- Parameters:
type
- the given type- Returns:
- the message as the given type or null if not possible to covert to given type
- See Also:
getIn(Class)
-
hasOut
@Deprecated boolean hasOut()
Deprecated.usegetMessage()
Returns whether an OUT message has been set or not.- Returns:
- true if an OUT message exists, false otherwise.
-
setOut
@Deprecated void setOut(Message out)
Deprecated.Sets the outbound message- Parameters:
out
- the outbound message
-
getException
Exception getException()
Returns the exception associated with this exchange- Returns:
- the exception (or null if no faults)
-
getException
<T> T getException(Class<T> type)
Returns the exception associated with this exchange. Is used to get the caused exception that typically have been wrapped in some sort of Camel wrapper exception The strategy is to look in the exception hierarchy to find the first given cause that matches the type. Will start from the bottom (the real cause) and walk upwards.- Parameters:
type
- the exception type- Returns:
- the exception (or null if no caused exception matched)
-
setException
void setException(Throwable t)
Sets the exception associated with this exchange Camel will wrapThrowable
intoException
type to accommodate for thegetException()
method returning a plainException
type.- Parameters:
t
- the caused exception
-
isFailed
boolean isFailed()
Returns true if this exchange failed due to an exception- Returns:
- true if this exchange failed due to an exception
- See Also:
getException()
-
isTransacted
boolean isTransacted()
Returns true if this exchange is transacted
-
isRouteStop
boolean isRouteStop()
Returns true if this exchange is marked to stop and not continue routing.
-
setRouteStop
void setRouteStop(boolean routeStop)
Sets whether this exchange is marked to stop and not continue routing.- Parameters:
routeStop
- true to stop routing
-
isExternalRedelivered
boolean isExternalRedelivered()
Returns true if this exchange is an external initiated redelivered message (such as a JMS broker). Important: It is not always possible to determine if the message is a redelivery or not, and therefore false is returned. Such an example would be a JDBC message. However JMS brokers provides details if a message is redelivered.- Returns:
- true if redelivered, false if not or not able to determine
-
isRollbackOnly
boolean isRollbackOnly()
Returns true if this exchange is marked for rollback
-
setRollbackOnly
void setRollbackOnly(boolean rollbackOnly)
Sets whether to mark this exchange for rollback
-
isRollbackOnlyLast
boolean isRollbackOnlyLast()
Returns true if this exchange is marked for rollback (only last transaction section)
-
setRollbackOnlyLast
void setRollbackOnlyLast(boolean rollbackOnlyLast)
Sets whether to mark this exchange for rollback (only last transaction section)
-
getContext
CamelContext getContext()
Returns the container so that a processor can resolve endpoints from URIs- Returns:
- the container which owns this exchange
-
copy
Exchange copy()
Creates a copy of the current message exchange so that it can be forwarded to another destination
-
getFromEndpoint
Endpoint getFromEndpoint()
Returns the endpoint which originated this message exchange if a consumer on an endpoint created the message exchange, otherwise his property will be null. Note: In case this message exchange has been cloned through another parent message exchange (which itself has been created through the consumer of it's own endpoint), then if desired one could still retrieve the consumer endpoint of such a parent message exchange as the following:getContext().getRoute(getFromRouteId()).getEndpoint()
-
getFromRouteId
String getFromRouteId()
Returns the route id which originated this message exchange if a route consumer on an endpoint created the message exchange, otherwise his property will be null. Note: In case this message exchange has been cloned through another parent message exchange then this method would return the fromRouteId property of that exchange.
-
getUnitOfWork
UnitOfWork getUnitOfWork()
Returns the unit of work that this exchange belongs to; which may map to zero, one or more physical transactions
-
getExchangeId
String getExchangeId()
Returns the exchange id (unique)
-
setExchangeId
void setExchangeId(String id)
Set the exchange id
-
getCreated
long getCreated()
Gets the timestamp in millis when this exchange was created.- See Also:
Message.getMessageTimestamp()
-
-