Package org.apache.camel
Interface Exchange
- All Superinterfaces:
VariableAware
- All Known Subinterfaces:
PooledExchange
@ConstantProvider("org.apache.camel.ExchangeConstantProvider")
public interface Exchange
extends VariableAware
An Exchange is the message container holding the information during the entire routing of a
which you could populate. As an alternative
you could also instantiate your specialized
Message received
by a Consumer.
During processing down the Processor chain, the Exchange provides access to the current (not the
original) request and response Message messages. The Exchange also holds meta-data during its entire
lifetime stored as properties accessible using the various getProperty(String) methods. The
setProperty(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 an Exchange failed during
routing the Exception that caused the failure is stored and accessible via the getException()
method.
An Exchange is created when a Consumer receives a request. A new Message is created, the request is
set as the body of the Message and depending on the Consumer other Endpoint and protocol
related information is added as headers on the Message. Then an Exchange is created and the newly created
Message is set as the in on the Exchange. Therefore, an Exchange starts its life in a Consumer. The
Exchange is then sent down the Route for processing along a Processor chain. The Processor as
the name suggests is what processes the Message 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 out Message produced by the previous Processor and set it as the in for the next
Processor. If the previous Processor did not produce an out, then the in of the previous
Processor is sent as the next in. At the end of the processing chain, depending on the Message Exchange Pattern (or MEP) the last out (or in of no out available) is sent by the Consumer 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 a Processor, it always contains an in Message and no
out Message. The Processor may produce an out, depending on the nature of the
Processor. The in Message can be accessed using the getIn() method. Since the out message is
null when entering the Processor, the getOut() method is actually a convenient factory method that
will lazily instantiate a
invalid reference
org.apache.camel.support.DefaultMessage
Message and set it on the exchange using the
setOut(org.apache.camel.Message) method. Please note that a Message contains not only the body but
also headers and attachments. If you are creating a new Message the headers and attachments of the in
Message are not automatically copied to the out by Camel, and you'll have to set the headers and attachments
you need yourself. If your Processor is not producing a different Message but only needs to slightly
modify the in, you can simply update the in Message returned by getIn().
See this FAQ entry for more
details.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDeprecated.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringDeprecated.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringDeprecated.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringDeprecated.static final Stringstatic final Stringstatic final Stringstatic final StringDeprecated.static final Stringstatic final StringDeprecated.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringDeprecated.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringDeprecated.static final StringDeprecated.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringDeprecated.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringDeprecated.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringDeprecated.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringDeprecated.static final StringDeprecated.static final StringDeprecated.static final Stringstatic final StringDeprecated.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringDeprecated.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringDeprecated.static final StringDeprecated.static final StringDeprecated.static final StringDeprecated.static final StringDeprecated.static final StringDeprecated.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a copy of the current message exchange so that it can be forwarded to another destinationReturns all (both internal and custom) properties associated with the exchangegetClock()GetsClockthat holds time information about the exchangeReturns the container so that a processor can resolve endpoints from URIslongDeprecated.Returns the exception associated with this exchange<T> TgetException(Class<T> type) Returns the exception associated with this exchange.Gets theExchangeExtensionthat contains the extension points for internal exchange APIs.Returns the exchange id (unique)Returns the endpoint which originated this message exchange if a consumer on an endpoint created the message exchange, otherwise his property will be null.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.getIn()Returns the inbound request message<T> TReturns the inbound request message as the given typeReturns the current message<T> TgetMessage(Class<T> type) Returns the current message as the given typegetOut()Deprecated.<T> TDeprecated.Returns theExchangePattern(MEP) of this exchange.Returns the properties associated with the exchangegetProperty(String name) Returns a property associated with this exchange by name<T> TgetProperty(String name, Class<T> type) Returns a property associated with this exchange by name and specifying the type required<T> TgetProperty(String name, Object defaultValue, Class<T> type) Returns a property associated with this exchange by name and specifying the type requiredReturns a property associated with this exchange by the key<T> TgetProperty(ExchangePropertyKey key, Class<T> type) Returns a property associated with this exchange by the key and specifying the type required<T> TgetProperty(ExchangePropertyKey key, Object defaultValue, Class<T> type) Returns a property associated with this exchange by name and specifying the type requiredReturns the unit of work that this exchange belongs to; which may map to zero, one or more physical transactionsgetVariable(String name) Returns a variable by name<T> TgetVariable(String name, Class<T> type) Returns a variable by name and specifying the type required<T> TgetVariable(String name, Object defaultValue, Class<T> type) Returns a variable by name and specifying the type requiredReturns the variables from the current exchangebooleanhasOut()Deprecated.usegetMessage()booleanReturns whether any properties have been setbooleanReturns whether any variables have been set on the current exchangebooleanReturns true if this exchange is an external initiated redelivered message (such as a JMS broker).booleanisFailed()Returns true if this exchange failed due to an exceptionbooleanReturns true if this exchange is marked for rollbackbooleanReturns true if this exchange is marked for rollback (only last transaction section)booleanReturns true if this exchange is marked to stop and not continue routing.booleanReturns true if this exchange is transactedbooleanremoveProperties(String pattern) Remove all the properties associated with the exchange matching a specific patternbooleanremoveProperties(String pattern, String... excludePatterns) Removes the properties from this exchange that match the given pattern, except for the ones matching one or more excludePatternsremoveProperty(String name) Removes the given property on the exchangeRemoves the given property on the exchangeremoveVariable(String name) Removes the given variable If the name is * then all variables from the current exchange is removed, and null is returned.voidSets the exception associated with this exchangevoidsetExchangeId(String id) Set the exchange idvoidSets the inbound message instancevoidsetMessage(Message message) Replace the current message instance.voidDeprecated.voidsetPattern(ExchangePattern pattern) Allows theExchangePattern(MEP) of this exchange to be customized.voidsetProperty(String name, Object value) Sets a property on the exchangevoidsetProperty(ExchangePropertyKey key, Object value) Sets a property on the exchangevoidsetRollbackOnly(boolean rollbackOnly) Sets whether to mark this exchange for rollbackvoidsetRollbackOnlyLast(boolean rollbackOnlyLast) Sets whether to mark this exchange for rollback (only last transaction section)voidsetRouteStop(boolean routeStop) Sets whether this exchange is marked to stop and not continue routing.voidsetVariable(String name, Object value) Sets a variable on the exchange
-
Field Details
-
ACTIVE_SPAN
- See Also:
-
CLOSE_CLIENT_SCOPE
- See Also:
-
AUTHENTICATION
- See Also:
-
AUTHENTICATION_FAILURE_POLICY_ID
- See Also:
-
ACCEPT_CONTENT_TYPE
Deprecated.- See Also:
-
AGGREGATED_SIZE
@Metadata(label="aggregate", description="Number of exchanges that was grouped together.", javaType="int") static final String AGGREGATED_SIZE- See Also:
-
AGGREGATED_TIMEOUT
@Metadata(label="aggregate", description="The time in millis this group will timeout", javaType="long") static final String AGGREGATED_TIMEOUT- See Also:
-
AGGREGATED_COMPLETED_BY
@Metadata(label="aggregate", description="Enum that tell how this group was completed", enums="consumer,force,interval,predicate,size,strategy,timeout", javaType="String") static final String AGGREGATED_COMPLETED_BY- See Also:
-
AGGREGATED_CORRELATION_KEY
@Metadata(label="aggregate", description="The correlation key for this aggregation group", javaType="String") static final String AGGREGATED_CORRELATION_KEY- See Also:
-
AGGREGATED_COLLECTION_GUARD
- See Also:
-
AGGREGATION_STRATEGY
- See Also:
-
AGGREGATION_COMPLETE_CURRENT_GROUP
@Metadata(label="consumer,aggregate", description="Input property. Set to true to force completing the current group. This allows to overrule any existing completion predicates, sizes, timeouts etc, and complete the group.", javaType="boolean") static final String AGGREGATION_COMPLETE_CURRENT_GROUP- See Also:
-
AGGREGATION_COMPLETE_ALL_GROUPS
@Metadata(label="consumer,aggregate", description="Input property. Set to true to force completing all the groups (excluding this message). This allows to overrule any existing completion predicates, sizes, timeouts etc, and complete the group. This message is considered a signal message only, the message headers/contents will not be processed otherwise. Instead use CamelAggregationCompleteAllGroupsInclusive if this message should be included in the aggregator.", javaType="boolean") static final String AGGREGATION_COMPLETE_ALL_GROUPS- See Also:
-
AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE
@Metadata(label="consumer,aggregate", description="Input property. Set to true to force completing all the groups (including this message). This allows to overrule any existing completion predicates, sizes, timeouts etc, and complete the group.", javaType="boolean") static final String AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE- See Also:
-
ASYNC_WAIT
- See Also:
-
BATCH_INDEX
- See Also:
-
BATCH_SIZE
- See Also:
-
BATCH_COMPLETE
- See Also:
-
BEAN_METHOD_NAME
- See Also:
-
BINDING
- See Also:
-
BREADCRUMB_ID
- See Also:
-
CHARSET_NAME
- See Also:
-
CIRCUIT_BREAKER_STATE
Deprecated.- See Also:
-
CREATED_TIMESTAMP
Deprecated.- See Also:
-
CLAIM_CHECK_REPOSITORY
- See Also:
-
CONTENT_ENCODING
- See Also:
-
CONTENT_LENGTH
- See Also:
-
CONTENT_TYPE
- See Also:
-
COOKIE_HANDLER
- See Also:
-
CORRELATION_ID
- See Also:
-
CONTENT_SCHEMA
- See Also:
-
CONTENT_SCHEMA_TYPE
- See Also:
-
DATASET_INDEX
- See Also:
-
DEFAULT_CHARSET_PROPERTY
- See Also:
-
DESTINATION_OVERRIDE_URL
- See Also:
-
DISABLE_HTTP_STREAM_CACHE
- See Also:
-
DUPLICATE_MESSAGE
@Metadata(label="idempotentConsumer", description="Whether this exchange is a duplicate detected by the Idempotent Consumer EIP", javaType="boolean") static final String DUPLICATE_MESSAGE- See Also:
-
DOCUMENT_BUILDER_FACTORY
- See Also:
-
EXCEPTION_CAUGHT
@Metadata(label="doCatch,doFinally,errorHandler,onException", description="Stores the caught exception due to a processing error of the current Exchange", javaType="java.lang.Exception") static final String EXCEPTION_CAUGHT- See Also:
-
EXCEPTION_HANDLED
- See Also:
-
EVALUATE_EXPRESSION_RESULT
- See Also:
-
ERRORHANDLER_BRIDGE
- See Also:
-
ERRORHANDLER_CIRCUIT_DETECTED
- See Also:
-
ERRORHANDLER_HANDLED
Deprecated.- See Also:
-
EXTERNAL_REDELIVERED
Deprecated.- See Also:
-
FAILURE_HANDLED
Deprecated.- See Also:
-
FAILURE_ENDPOINT
@Metadata(label="doCatch,doFinally,errorHandler,onException", description="Endpoint URI where the Exchange failed during processing", javaType="String") static final String FAILURE_ENDPOINT- See Also:
-
FAILURE_ROUTE_ID
@Metadata(label="doCatch,doFinally,errorHandler,onException", description="Route ID where the Exchange failed during processing", javaType="String") static final String FAILURE_ROUTE_ID- See Also:
-
FATAL_FALLBACK_ERROR_HANDLER
- See Also:
-
FILE_CONTENT_TYPE
- See Also:
-
FILE_LOCAL_WORK_PATH
- See Also:
-
FILE_NAME
- See Also:
-
FILE_NAME_ONLY
- See Also:
-
FILE_NAME_PRODUCED
- See Also:
-
FILE_NAME_CONSUMED
- See Also:
-
FILE_PATH
- See Also:
-
FILE_PARENT
- See Also:
-
FILE_LAST_MODIFIED
- See Also:
-
FILE_LENGTH
- See Also:
-
FILE_LOCK_FILE_ACQUIRED
- See Also:
-
FILE_LOCK_FILE_NAME
- See Also:
-
FILE_LOCK_EXCLUSIVE_LOCK
- See Also:
-
FILE_LOCK_RANDOM_ACCESS_FILE
- See Also:
-
FILE_LOCK_CHANNEL_FILE
- See Also:
-
FILE_EXCHANGE_FILE
- See Also:
-
FILTER_MATCHED
Deprecated.- See Also:
-
FILTER_NON_XML_CHARS
- See Also:
-
GROUPED_EXCHANGE
- See Also:
-
HTTP_SCHEME
- See Also:
-
HTTP_HOST
- See Also:
-
HTTP_PORT
- See Also:
-
HTTP_BASE_URI
- See Also:
-
HTTP_CHARACTER_ENCODING
- See Also:
-
HTTP_METHOD
- See Also:
-
HTTP_PATH
- See Also:
-
HTTP_PROTOCOL_VERSION
- See Also:
-
HTTP_QUERY
- See Also:
-
HTTP_RAW_QUERY
- See Also:
-
HTTP_RESPONSE_CODE
- See Also:
-
HTTP_RESPONSE_TEXT
- See Also:
-
HTTP_URI
- See Also:
-
HTTP_URL
- See Also:
-
HTTP_CHUNKED
- See Also:
-
HTTP_SERVLET_REQUEST
Deprecated.- See Also:
-
HTTP_SERVLET_RESPONSE
Deprecated.- See Also:
-
INTERCEPTED_ENDPOINT
@Metadata(label="interceptFrom,interceptSendToEndpoint", description="The endpoint URI that was intercepted", javaType="String") static final String INTERCEPTED_ENDPOINT- See Also:
-
INTERCEPT_SEND_TO_ENDPOINT_WHEN_MATCHED
- See Also:
-
INTERRUPTED
Deprecated.- See Also:
-
LANGUAGE_SCRIPT
- See Also:
-
LOG_DEBUG_BODY_MAX_CHARS
- See Also:
-
LOG_DEBUG_BODY_STREAMS
- See Also:
-
LOG_EIP_NAME
- See Also:
-
LOOP_INDEX
@Metadata(label="loop", description="Index of the current iteration (0 based).", javaType="int") static final String LOOP_INDEX- See Also:
-
LOOP_SIZE
@Metadata(label="loop", description="Total number of loops. This is not available if running the loop in while loop mode.", javaType="int") static final String LOOP_SIZE- See Also:
-
SAGA_LONG_RUNNING_ACTION
- See Also:
-
MAXIMUM_CACHE_POOL_SIZE
- See Also:
-
MAXIMUM_ENDPOINT_CACHE_SIZE
- See Also:
-
MAXIMUM_SIMPLE_CACHE_SIZE
- See Also:
-
MAXIMUM_TRANSFORMER_CACHE_SIZE
- See Also:
-
MAXIMUM_VALIDATOR_CACHE_SIZE
- See Also:
-
MESSAGE_HISTORY
- See Also:
-
MESSAGE_HISTORY_HEADER_FORMAT
- See Also:
-
MESSAGE_HISTORY_OUTPUT_FORMAT
- See Also:
-
MESSAGE_TIMESTAMP
- See Also:
-
MULTICAST_INDEX
@Metadata(label="multicast", description="An index counter that increases for each Exchange being multicasted. The counter starts from 0.", javaType="int") static final String MULTICAST_INDEX- See Also:
-
MULTICAST_COMPLETE
@Metadata(label="multicast", description="Whether this Exchange is the last.", javaType="boolean") static final String MULTICAST_COMPLETE- See Also:
-
NOTIFY_EVENT
Deprecated.- See Also:
-
ON_COMPLETION
@Metadata(label="onCompletion", description="Flag to mark that this exchange is currently being executed as onCompletion", javaType="boolean") static final String ON_COMPLETION- See Also:
-
ON_COMPLETION_ROUTE_IDS
- See Also:
-
OFFSET
- See Also:
-
OVERRULE_FILE_NAME
- See Also:
-
PARENT_UNIT_OF_WORK
- See Also:
-
STREAM_CACHE_UNIT_OF_WORK
- See Also:
-
RECIPIENT_LIST_ENDPOINT
@Metadata(label="recipientList", description="The endpoint uri of this recipient list", javaType="String") static final String RECIPIENT_LIST_ENDPOINT- See Also:
-
RECEIVED_TIMESTAMP
- See Also:
-
REDELIVERED
- See Also:
-
REDELIVERY_COUNTER
- See Also:
-
REDELIVERY_MAX_COUNTER
- See Also:
-
REDELIVERY_EXHAUSTED
Deprecated.- See Also:
-
REDELIVERY_DELAY
- See Also:
-
REST_HTTP_URI
- See Also:
-
REST_HTTP_QUERY
- See Also:
-
REST_OPENAPI
- See Also:
-
ROLLBACK_ONLY
Deprecated.- See Also:
-
ROLLBACK_ONLY_LAST
Deprecated.- See Also:
-
ROUTE_STOP
Deprecated.- See Also:
-
REUSE_SCRIPT_ENGINE
- See Also:
-
COMPILE_SCRIPT
- See Also:
-
SAXPARSER_FACTORY
Deprecated.- See Also:
-
SCHEDULER_POLLED_MESSAGES
- See Also:
-
SOAP_ACTION
Deprecated.- See Also:
-
SKIP_GZIP_ENCODING
- See Also:
-
SKIP_WWW_FORM_URLENCODED
- See Also:
-
SLIP_ENDPOINT
@Metadata(label="routingSlip", description="The endpoint uri of this routing slip", javaType="String") static final String SLIP_ENDPOINT- See Also:
-
SLIP_PRODUCER
- See Also:
-
SPLIT_INDEX
@Metadata(label="split", description="A split counter that increases for each Exchange being split. The counter starts from 0.", javaType="int") static final String SPLIT_INDEX- See Also:
-
SPLIT_COMPLETE
@Metadata(label="split", description="Whether this Exchange is the last.", javaType="boolean") static final String SPLIT_COMPLETE- See Also:
-
SPLIT_SIZE
@Metadata(label="split", description="The total number of Exchanges that was split. This property is not applied for stream based splitting, except for the very last message because then Camel knows the total size.", javaType="int") static final String SPLIT_SIZE- See Also:
-
STEP_ID
@Metadata(label="step", description="The id of the Step EIP", javaType="String") static final String STEP_ID- See Also:
-
TIMER_COUNTER
- See Also:
-
TIMER_FIRED_TIME
- See Also:
-
TIMER_NAME
- See Also:
-
TIMER_PERIOD
- See Also:
-
TIMER_TIME
- See Also:
-
TO_ENDPOINT
@Metadata(label="enrich,multicast,pollEnrich,recipientList,routingSlip,toD,to,wireTap", description="Endpoint URI where this Exchange is being sent to", javaType="String") static final String TO_ENDPOINT- See Also:
-
TRACE_EVENT
Deprecated.- See Also:
-
TRACE_EVENT_NODE_ID
Deprecated.- See Also:
-
TRACE_EVENT_TIMESTAMP
Deprecated.- See Also:
-
TRACE_EVENT_EXCHANGE
Deprecated.- See Also:
-
TRACING_HEADER_FORMAT
Deprecated.- See Also:
-
TRACING_OUTPUT_FORMAT
Deprecated.- See Also:
-
TRANSACTION_CONTEXT_DATA
- See Also:
-
TRY_ROUTE_BLOCK
- See Also:
-
TRANSFER_ENCODING
- See Also:
-
UNIT_OF_WORK_EXHAUSTED
- See Also:
-
XSLT_FILE_NAME
- See Also:
-
XSLT_ERROR
- See Also:
-
XSLT_FATAL_ERROR
- See Also:
-
XSLT_WARNING
- See Also:
-
-
Method Details
-
getPattern
ExchangePattern getPattern()Returns theExchangePattern(MEP) of this exchange.- Returns:
- the message exchange pattern of this exchange
-
setPattern
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
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
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
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
Sets a property on the exchange- Parameters:
key- the exchange keyvalue- to associate with the name
-
removeProperty
Removes the given property on the exchange- Parameters:
key- the exchange key- Returns:
- the old value of the property
-
getProperty
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
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
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
Sets a property on the exchange- Parameters:
name- of the propertyvalue- to associate with the name
-
removeProperty
Removes the given property on the exchange- Parameters:
name- of the property- Returns:
- the old value of the property
-
removeProperties
Remove all the properties associated with the exchange matching a specific pattern- Parameters:
pattern- pattern of names- Returns:
- boolean whether any properties matched
-
removeProperties
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
Returns the properties associated with the exchange- Returns:
- the properties in a Map
- See Also:
-
getAllProperties
Returns all (both internal and custom) properties associated with the exchange- Returns:
- all (both internal and custom) properties in a Map
- See Also:
-
hasProperties
boolean hasProperties()Returns whether any properties have been set- Returns:
- true if any property has been set
-
getVariable
Returns a variable by name- Specified by:
getVariablein interfaceVariableAware- Parameters:
name- the variable name. Can be prefixed with repo-id:name to lookup the variable from a specific repository. If no repo-id is provided, then variables will be from the current exchange.- Returns:
- the value of the given variable or null if there is no variable for the given name
-
getVariable
Returns a variable by name and specifying the type required- Parameters:
name- the variable name. Can be prefixed with repo-id:name to lookup the variable from a specific repository. If no repo-id is provided, then variables will be from the current exchange.type- the type of the variable- Returns:
- the value of the given variable or null if there is no variable for the given name or null if it cannot be converted to the given type
-
getVariable
Returns a variable by name and specifying the type required- Parameters:
name- the variable name. Can be prefixed with repo-id:name to look up the variable from a specific repository. If no repo-id is provided, then variables will be from the current exchange.defaultValue- the default value to return if variable was absenttype- the type of the variable- Returns:
- the value of the given variable or defaultValue if there is no variable for the given name or null if it cannot be converted to the given type
-
setVariable
Sets a variable on the exchange- Specified by:
setVariablein interfaceVariableAware- Parameters:
name- the variable name. Can be prefixed with repo-id:name to store the variable in a specific repository. If no repo-id is provided, then variables will be stored in the current exchange.value- the value of the variable
-
removeVariable
Removes the given variable If the name is * then all variables from the current exchange is removed, and null is returned.- Parameters:
name- the variable name. Can be prefixed with repo-id:name to remove the variable in a specific repository. If no repo-id is provided, then the variable from the current exchange will be removed- Returns:
- the old value of the variable, or null if there was no variable for the given name
-
getVariables
Returns the variables from the current exchange- Returns:
- the variables from the current exchange in a Map.
-
hasVariables
boolean hasVariables()Returns whether any variables have been set on the current exchange- Returns:
- true if any variables has been set on the current exchange
-
getIn
Message getIn()Returns the inbound request message- Returns:
- the message
-
getMessage
Message getMessage()Returns the current message- Returns:
- the current message
-
getMessage
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
Replace the current message instance.- Parameters:
message- the new message
-
getIn
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
Sets the inbound message instance- Parameters:
in- the inbound 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 has been set or not, use thehasOut()method. See also the class Javadoc for thisExchangefor more details and this FAQ entry.- Returns:
- the response
- See Also:
-
getOut
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 has been set or not, use thehasOut()method. See also the class Javadoc for thisExchangefor 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:
-
hasOut
Deprecated.usegetMessage()Returns whether an OUT message has been set or not.- Returns:
- true if an OUT message exists, false otherwise.
-
setOut
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
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
Sets the exception associated with this exchange Camel will wrapThrowableintoExceptiontype to accommodate for thegetException()method returning a plainExceptiontype.- 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:
-
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
Set the exchange id -
getCreated
Deprecated.Gets the timestamp in millis when this exchange was created.- See Also:
-
getExchangeExtension
ExchangeExtension getExchangeExtension()Gets theExchangeExtensionthat contains the extension points for internal exchange APIs. These APIs are intended for internal usage within Camel and end-users should avoid using them.- Returns:
- the
ExchangeExtensionpoint for this exchange.
-
getClock
Clock getClock()GetsClockthat holds time information about the exchange
-
getMessage()