001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel; 018 019import java.util.Date; 020import java.util.List; 021import java.util.Map; 022 023import org.apache.camel.spi.Synchronization; 024import org.apache.camel.spi.UnitOfWork; 025 026/** 027 * An Exchange is the message container holding the information during the entire routing of 028 * a {@link Message} received by a {@link Consumer}. 029 * <p/> 030 * During processing down the {@link Processor} chain, the {@link Exchange} provides access to the 031 * current (not the original) request and response {@link Message} messages. The {@link Exchange} 032 * also holds meta-data during its entire lifetime stored as properties accessible using the 033 * various {@link #getProperty(String)} methods. The {@link #setProperty(String, Object)} is 034 * used to store a property. For example you can use this to store security, SLA related 035 * data or any other information deemed useful throughout processing. If an {@link Exchange} 036 * failed during routing the {@link Exception} that caused the failure is stored and accessible 037 * via the {@link #getException()} method. 038 * <p/> 039 * An Exchange is created when a {@link Consumer} receives a request. A new {@link Message} is 040 * created, the request is set as the body of the {@link Message} and depending on the {@link Consumer} 041 * other {@link Endpoint} and protocol related information is added as headers on the {@link Message}. 042 * Then an Exchange is created and the newly created {@link Message} is set as the in on the Exchange. 043 * Therefore an Exchange starts its life in a {@link Consumer}. The Exchange is then sent down the 044 * {@link Route} for processing along a {@link Processor} chain. The {@link Processor} as the name 045 * suggests is what processes the {@link Message} in the Exchange and Camel, in addition to 046 * providing out-of-the-box a large number of useful processors, it also allows you to create your own. 047 * The rule Camel uses is to take the out {@link Message} produced by the previous {@link Processor} 048 * and set it as the in for the next {@link Processor}. If the previous {@link Processor} did not 049 * produce an out, then the in of the previous {@link Processor} is sent as the next in. At the 050 * end of the processing chain, depending on the {@link ExchangePattern Message Exchange Pattern} (or MEP) 051 * the last out (or in of no out available) is sent by the {@link Consumer} back to the original caller. 052 * <p/> 053 * Camel, in addition to providing out-of-the-box a large number of useful processors, it also allows 054 * you to implement and use your own. When the Exchange is passed to a {@link Processor}, it always 055 * contains an in {@link Message} and no out {@link Message}. The {@link Processor} <b>may</b> produce 056 * an out, depending on the nature of the {@link Processor}. The in {@link Message} can be accessed 057 * using the {@link #getIn()} method. Since the out message is null when entering the {@link Processor}, 058 * the {@link #getOut()} method is actually a convenient factory method that will lazily instantiate a 059 * {@link org.apache.camel.impl.DefaultMessage} which you could populate. As an alternative you could 060 * also instantiate your specialized {@link Message} and set it on the exchange using the 061 * {@link #setOut(org.apache.camel.Message)} method. Please note that a {@link Message} contains not only 062 * the body but also headers and attachments. If you are creating a new {@link Message} the headers and 063 * attachments of the in {@link Message} are not automatically copied to the out by Camel and you'll have 064 * to set the headers and attachments you need yourself. If your {@link Processor} is not producing a 065 * different {@link Message} but only needs to slightly modify the in, you can simply update the in 066 * {@link Message} returned by {@link #getIn()}. 067 * <p/> 068 * See this <a href="http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html">FAQ entry</a> 069 * for more details. 070 * 071 */ 072public interface Exchange { 073 074 String AUTHENTICATION = "CamelAuthentication"; 075 String AUTHENTICATION_FAILURE_POLICY_ID = "CamelAuthenticationFailurePolicyId"; 076 @Deprecated 077 String ACCEPT_CONTENT_TYPE = "CamelAcceptContentType"; 078 String AGGREGATED_SIZE = "CamelAggregatedSize"; 079 String AGGREGATED_TIMEOUT = "CamelAggregatedTimeout"; 080 String AGGREGATED_COMPLETED_BY = "CamelAggregatedCompletedBy"; 081 String AGGREGATED_CORRELATION_KEY = "CamelAggregatedCorrelationKey"; 082 String AGGREGATED_COLLECTION_GUARD = "CamelAggregatedCollectionGuard"; 083 String AGGREGATION_STRATEGY = "CamelAggregationStrategy"; 084 String AGGREGATION_COMPLETE_CURRENT_GROUP = "CamelAggregationCompleteCurrentGroup"; 085 String AGGREGATION_COMPLETE_ALL_GROUPS = "CamelAggregationCompleteAllGroups"; 086 String AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE = "CamelAggregationCompleteAllGroupsInclusive"; 087 String ASYNC_WAIT = "CamelAsyncWait"; 088 089 String BATCH_INDEX = "CamelBatchIndex"; 090 String BATCH_SIZE = "CamelBatchSize"; 091 String BATCH_COMPLETE = "CamelBatchComplete"; 092 String BEAN_METHOD_NAME = "CamelBeanMethodName"; 093 @Deprecated 094 String BEAN_MULTI_PARAMETER_ARRAY = "CamelBeanMultiParameterArray"; 095 String BINDING = "CamelBinding"; 096 // do not prefix with Camel and use lower-case starting letter as its a shared key 097 // used across other Apache products such as AMQ, SMX etc. 098 String BREADCRUMB_ID = "breadcrumbId"; 099 100 String CHARSET_NAME = "CamelCharsetName"; 101 String CIRCUIT_BREAKER_STATE = "CamelCircuitBreakerState"; 102 String CREATED_TIMESTAMP = "CamelCreatedTimestamp"; 103 String CLAIM_CHECK_REPOSITORY = "CamelClaimCheckRepository"; 104 String CONTENT_ENCODING = "Content-Encoding"; 105 String CONTENT_LENGTH = "Content-Length"; 106 String CONTENT_TYPE = "Content-Type"; 107 String COOKIE_HANDLER = "CamelCookieHandler"; 108 String CORRELATION_ID = "CamelCorrelationId"; 109 110 String DATASET_INDEX = "CamelDataSetIndex"; 111 String DEFAULT_CHARSET_PROPERTY = "org.apache.camel.default.charset"; 112 String DESTINATION_OVERRIDE_URL = "CamelDestinationOverrideUrl"; 113 String DISABLE_HTTP_STREAM_CACHE = "CamelDisableHttpStreamCache"; 114 String DUPLICATE_MESSAGE = "CamelDuplicateMessage"; 115 116 String DOCUMENT_BUILDER_FACTORY = "CamelDocumentBuilderFactory"; 117 118 String EXCEPTION_CAUGHT = "CamelExceptionCaught"; 119 String EXCEPTION_HANDLED = "CamelExceptionHandled"; 120 String EVALUATE_EXPRESSION_RESULT = "CamelEvaluateExpressionResult"; 121 String ERRORHANDLER_CIRCUIT_DETECTED = "CamelFErrorHandlerCircuitDetected"; 122 String ERRORHANDLER_HANDLED = "CamelErrorHandlerHandled"; 123 String EXTERNAL_REDELIVERED = "CamelExternalRedelivered"; 124 125 String FAILURE_HANDLED = "CamelFailureHandled"; 126 String FAILURE_ENDPOINT = "CamelFailureEndpoint"; 127 String FAILURE_ROUTE_ID = "CamelFailureRouteId"; 128 String FATAL_FALLBACK_ERROR_HANDLER = "CamelFatalFallbackErrorHandler"; 129 String FILE_CONTENT_TYPE = "CamelFileContentType"; 130 String FILE_LOCAL_WORK_PATH = "CamelFileLocalWorkPath"; 131 String FILE_NAME = "CamelFileName"; 132 String FILE_NAME_ONLY = "CamelFileNameOnly"; 133 String FILE_NAME_PRODUCED = "CamelFileNameProduced"; 134 String FILE_NAME_CONSUMED = "CamelFileNameConsumed"; 135 String FILE_PATH = "CamelFilePath"; 136 String FILE_PARENT = "CamelFileParent"; 137 String FILE_LAST_MODIFIED = "CamelFileLastModified"; 138 String FILE_LENGTH = "CamelFileLength"; 139 String FILE_LOCK_FILE_ACQUIRED = "CamelFileLockFileAcquired"; 140 String FILE_LOCK_FILE_NAME = "CamelFileLockFileName"; 141 String FILE_LOCK_EXCLUSIVE_LOCK = "CamelFileLockExclusiveLock"; 142 String FILE_LOCK_RANDOM_ACCESS_FILE = "CamelFileLockRandomAccessFile"; 143 String FILTER_MATCHED = "CamelFilterMatched"; 144 String FILTER_NON_XML_CHARS = "CamelFilterNonXmlChars"; 145 146 String GROUPED_EXCHANGE = "CamelGroupedExchange"; 147 148 String HTTP_SCHEME = "CamelHttpScheme"; 149 String HTTP_HOST = "CamelHttpHost"; 150 String HTTP_PORT = "CamelHttpPort"; 151 String HTTP_BASE_URI = "CamelHttpBaseUri"; 152 String HTTP_CHARACTER_ENCODING = "CamelHttpCharacterEncoding"; 153 String HTTP_METHOD = "CamelHttpMethod"; 154 String HTTP_PATH = "CamelHttpPath"; 155 String HTTP_PROTOCOL_VERSION = "CamelHttpProtocolVersion"; 156 String HTTP_QUERY = "CamelHttpQuery"; 157 String HTTP_RAW_QUERY = "CamelHttpRawQuery"; 158 String HTTP_RESPONSE_CODE = "CamelHttpResponseCode"; 159 String HTTP_RESPONSE_TEXT = "CamelHttpResponseText"; 160 String HTTP_URI = "CamelHttpUri"; 161 String HTTP_URL = "CamelHttpUrl"; 162 String HTTP_CHUNKED = "CamelHttpChunked"; 163 String HTTP_SERVLET_REQUEST = "CamelHttpServletRequest"; 164 String HTTP_SERVLET_RESPONSE = "CamelHttpServletResponse"; 165 166 String INTERCEPTED_ENDPOINT = "CamelInterceptedEndpoint"; 167 String INTERCEPT_SEND_TO_ENDPOINT_WHEN_MATCHED = "CamelInterceptSendToEndpointWhenMatched"; 168 String INTERRUPTED = "CamelInterrupted"; 169 170 String LANGUAGE_SCRIPT = "CamelLanguageScript"; 171 String LOG_DEBUG_BODY_MAX_CHARS = "CamelLogDebugBodyMaxChars"; 172 String LOG_DEBUG_BODY_STREAMS = "CamelLogDebugStreams"; 173 String LOG_EIP_NAME = "CamelLogEipName"; 174 String LOOP_INDEX = "CamelLoopIndex"; 175 String LOOP_SIZE = "CamelLoopSize"; 176 177 // Long running action (saga): using "Long-Running-Action" as header value allows sagas 178 // to be propagated to any remote system supporting the LRA framework 179 String SAGA_LONG_RUNNING_ACTION = "Long-Running-Action"; 180 181 String MAXIMUM_CACHE_POOL_SIZE = "CamelMaximumCachePoolSize"; 182 String MAXIMUM_ENDPOINT_CACHE_SIZE = "CamelMaximumEndpointCacheSize"; 183 String MAXIMUM_SIMPLE_CACHE_SIZE = "CamelMaximumSimpleCacheSize"; 184 String MAXIMUM_TRANSFORMER_CACHE_SIZE = "CamelMaximumTransformerCacheSize"; 185 String MAXIMUM_VALIDATOR_CACHE_SIZE = "CamelMaximumValidatorCacheSize"; 186 String MESSAGE_HISTORY = "CamelMessageHistory"; 187 String MESSAGE_HISTORY_HEADER_FORMAT = "CamelMessageHistoryHeaderFormat"; 188 String MESSAGE_HISTORY_OUTPUT_FORMAT = "CamelMessageHistoryOutputFormat"; 189 String MULTICAST_INDEX = "CamelMulticastIndex"; 190 String MULTICAST_COMPLETE = "CamelMulticastComplete"; 191 192 String NOTIFY_EVENT = "CamelNotifyEvent"; 193 194 String ON_COMPLETION = "CamelOnCompletion"; 195 String OVERRULE_FILE_NAME = "CamelOverruleFileName"; 196 197 String PARENT_UNIT_OF_WORK = "CamelParentUnitOfWork"; 198 String STREAM_CACHE_UNIT_OF_WORK = "CamelStreamCacheUnitOfWork"; 199 200 String RECIPIENT_LIST_ENDPOINT = "CamelRecipientListEndpoint"; 201 String RECEIVED_TIMESTAMP = "CamelReceivedTimestamp"; 202 String REDELIVERED = "CamelRedelivered"; 203 String REDELIVERY_COUNTER = "CamelRedeliveryCounter"; 204 String REDELIVERY_MAX_COUNTER = "CamelRedeliveryMaxCounter"; 205 String REDELIVERY_EXHAUSTED = "CamelRedeliveryExhausted"; 206 String REDELIVERY_DELAY = "CamelRedeliveryDelay"; 207 String REST_HTTP_URI = "CamelRestHttpUri"; 208 String REST_HTTP_QUERY = "CamelRestHttpQuery"; 209 String ROLLBACK_ONLY = "CamelRollbackOnly"; 210 String ROLLBACK_ONLY_LAST = "CamelRollbackOnlyLast"; 211 String ROUTE_STOP = "CamelRouteStop"; 212 213 String REUSE_SCRIPT_ENGINE = "CamelReuseScripteEngine"; 214 String COMPILE_SCRIPT = "CamelCompileScript"; 215 216 String SAXPARSER_FACTORY = "CamelSAXParserFactory"; 217 218 String SCHEDULER_POLLED_MESSAGES = "CamelSchedulerPolledMessages"; 219 String SOAP_ACTION = "CamelSoapAction"; 220 String SKIP_GZIP_ENCODING = "CamelSkipGzipEncoding"; 221 String SKIP_WWW_FORM_URLENCODED = "CamelSkipWwwFormUrlEncoding"; 222 String SLIP_ENDPOINT = "CamelSlipEndpoint"; 223 String SLIP_PRODUCER = "CamelSlipProducer"; 224 String SPLIT_INDEX = "CamelSplitIndex"; 225 String SPLIT_COMPLETE = "CamelSplitComplete"; 226 String SPLIT_SIZE = "CamelSplitSize"; 227 228 String TIMER_COUNTER = "CamelTimerCounter"; 229 String TIMER_FIRED_TIME = "CamelTimerFiredTime"; 230 String TIMER_NAME = "CamelTimerName"; 231 String TIMER_PERIOD = "CamelTimerPeriod"; 232 String TIMER_TIME = "CamelTimerTime"; 233 String TO_ENDPOINT = "CamelToEndpoint"; 234 String TRACE_EVENT = "CamelTraceEvent"; 235 String TRACE_EVENT_NODE_ID = "CamelTraceEventNodeId"; 236 String TRACE_EVENT_TIMESTAMP = "CamelTraceEventTimestamp"; 237 String TRACE_EVENT_EXCHANGE = "CamelTraceEventExchange"; 238 String TRY_ROUTE_BLOCK = "TryRouteBlock"; 239 String TRANSFER_ENCODING = "Transfer-Encoding"; 240 241 String UNIT_OF_WORK_EXHAUSTED = "CamelUnitOfWorkExhausted"; 242 243 /** 244 * @deprecated UNIT_OF_WORK_PROCESS_SYNC is not in use and will be removed in future Camel release 245 */ 246 @Deprecated 247 String UNIT_OF_WORK_PROCESS_SYNC = "CamelUnitOfWorkProcessSync"; 248 249 String XSLT_FILE_NAME = "CamelXsltFileName"; 250 String XSLT_ERROR = "CamelXsltError"; 251 String XSLT_FATAL_ERROR = "CamelXsltFatalError"; 252 String XSLT_WARNING = "CamelXsltWarning"; 253 254 /** 255 * Returns the {@link ExchangePattern} (MEP) of this exchange. 256 * 257 * @return the message exchange pattern of this exchange 258 */ 259 ExchangePattern getPattern(); 260 261 /** 262 * Allows the {@link ExchangePattern} (MEP) of this exchange to be customized. 263 * 264 * This typically won't be required as an exchange can be created with a specific MEP 265 * by calling {@link Endpoint#createExchange(ExchangePattern)} but it is here just in case 266 * it is needed. 267 * 268 * @param pattern the pattern 269 */ 270 void setPattern(ExchangePattern pattern); 271 272 /** 273 * Returns a property associated with this exchange by name 274 * 275 * @param name the name of the property 276 * @return the value of the given property or <tt>null</tt> if there is no property for 277 * the given name 278 */ 279 Object getProperty(String name); 280 281 /** 282 * Returns a property associated with this exchange by name 283 * 284 * @param name the name of the property 285 * @param defaultValue the default value to return if property was absent 286 * @return the value of the given property or <tt>defaultValue</tt> if there is no 287 * property for the given name 288 */ 289 Object getProperty(String name, Object defaultValue); 290 291 /** 292 * Returns a property associated with this exchange by name and specifying 293 * the type required 294 * 295 * @param name the name of the property 296 * @param type the type of the property 297 * @return the value of the given property or <tt>null</tt> if there is no property for 298 * the given name or <tt>null</tt> if it cannot be converted to the given type 299 */ 300 <T> T getProperty(String name, Class<T> type); 301 302 /** 303 * Returns a property associated with this exchange by name and specifying 304 * the type required 305 * 306 * @param name the name of the property 307 * @param defaultValue the default value to return if property was absent 308 * @param type the type of the property 309 * @return the value of the given property or <tt>defaultValue</tt> if there is no property for 310 * the given name or <tt>null</tt> if it cannot be converted to the given type 311 */ 312 <T> T getProperty(String name, Object defaultValue, Class<T> type); 313 314 /** 315 * Sets a property on the exchange 316 * 317 * @param name of the property 318 * @param value to associate with the name 319 */ 320 void setProperty(String name, Object value); 321 322 /** 323 * Removes the given property on the exchange 324 * 325 * @param name of the property 326 * @return the old value of the property 327 */ 328 Object removeProperty(String name); 329 330 /** 331 * Remove all of the properties associated with the exchange matching a specific pattern 332 * 333 * @param pattern pattern of names 334 * @return boolean whether any properties matched 335 */ 336 boolean removeProperties(String pattern); 337 338 /** 339 * Removes the properties from this exchange that match the given <tt>pattern</tt>, 340 * except for the ones matching one ore more <tt>excludePatterns</tt> 341 * 342 * @param pattern pattern of names that should be removed 343 * @param excludePatterns one or more pattern of properties names that should be excluded (= preserved) 344 * @return boolean whether any properties matched 345 */ 346 boolean removeProperties(String pattern, String... excludePatterns); 347 348 /** 349 * Returns all of the properties associated with the exchange 350 * 351 * @return all the headers in a Map 352 */ 353 Map<String, Object> getProperties(); 354 355 /** 356 * Returns whether any properties has been set 357 * 358 * @return <tt>true</tt> if any properties has been set 359 */ 360 boolean hasProperties(); 361 362 /** 363 * Returns the inbound request message 364 * 365 * @return the message 366 */ 367 Message getIn(); 368 369 /** 370 * Returns the current message 371 * 372 * @return the current message 373 */ 374 Message getMessage(); 375 376 /** 377 * Returns the current message as the given type 378 * 379 * @param type the given type 380 * @return the message as the given type or <tt>null</tt> if not possible to covert to given type 381 */ 382 <T> T getMessage(Class<T> type); 383 384 /** 385 * Replace the current message instance. 386 * 387 * @param message the new message 388 */ 389 void setMessage(Message message); 390 391 /** 392 * Returns the inbound request message as the given type 393 * 394 * @param type the given type 395 * @return the message as the given type or <tt>null</tt> if not possible to covert to given type 396 */ 397 <T> T getIn(Class<T> type); 398 399 /** 400 * Sets the inbound message instance 401 * 402 * @param in the inbound message 403 */ 404 void setIn(Message in); 405 406 /** 407 * Returns the outbound message, lazily creating one if one has not already 408 * been associated with this exchange. 409 * <p/> 410 * <br/><b>Important:</b> If you want to change the current message, then use {@link #getIn()} instead as it will 411 * ensure headers etc. is kept and propagated when routing continues. Bottom line end users should rarely use 412 * this method. 413 * <p/> 414 * <br/>If you want to test whether an OUT message have been set or not, use the {@link #hasOut()} method. 415 * <p/> 416 * See also the class java doc for this {@link Exchange} for more details and this 417 * <a href="http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html">FAQ entry</a>. 418 * 419 * @return the response 420 * @see #getIn() 421 */ 422 Message getOut(); 423 424 /** 425 * Returns the outbound request message as the given type 426 * <p/> 427 * <br/><b>Important:</b> If you want to change the current message, then use {@link #getIn()} instead as it will 428 * ensure headers etc. is kept and propagated when routing continues. Bottom line end users should rarely use 429 * this method. 430 * <p/> 431 * <br/>If you want to test whether an OUT message have been set or not, use the {@link #hasOut()} method. 432 * <p/> 433 * See also the class java doc for this {@link Exchange} for more details and this 434 * <a href="http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html">FAQ entry</a>. 435 * 436 * @param type the given type 437 * @return the message as the given type or <tt>null</tt> if not possible to covert to given type 438 * @see #getIn(Class) 439 */ 440 <T> T getOut(Class<T> type); 441 442 /** 443 * Returns whether an OUT message has been set or not. 444 * 445 * @return <tt>true</tt> if an OUT message exists, <tt>false</tt> otherwise. 446 */ 447 boolean hasOut(); 448 449 /** 450 * Sets the outbound message 451 * 452 * @param out the outbound message 453 */ 454 void setOut(Message out); 455 456 /** 457 * Returns the exception associated with this exchange 458 * 459 * @return the exception (or null if no faults) 460 */ 461 Exception getException(); 462 463 /** 464 * Returns the exception associated with this exchange. 465 * <p/> 466 * Is used to get the caused exception that typically have been wrapped in some sort 467 * of Camel wrapper exception 468 * <p/> 469 * The strategy is to look in the exception hierarchy to find the first given cause that matches the type. 470 * Will start from the bottom (the real cause) and walk upwards. 471 * 472 * @param type the exception type 473 * @return the exception (or <tt>null</tt> if no caused exception matched) 474 */ 475 <T> T getException(Class<T> type); 476 477 /** 478 * Sets the exception associated with this exchange 479 * <p/> 480 * Camel will wrap {@link Throwable} into {@link Exception} type to 481 * accommodate for the {@link #getException()} method returning a plain {@link Exception} type. 482 * 483 * @param t the caused exception 484 */ 485 void setException(Throwable t); 486 487 /** 488 * Returns true if this exchange failed due to either an exception or fault 489 * 490 * @return true if this exchange failed due to either an exception or fault 491 * @see Exchange#getException() 492 * @see Message#setFault(boolean) 493 * @see Message#isFault() 494 */ 495 boolean isFailed(); 496 497 /** 498 * Returns true if this exchange is transacted 499 */ 500 boolean isTransacted(); 501 502 /** 503 * Returns true if this exchange is an external initiated redelivered message (such as a JMS broker). 504 * <p/> 505 * <b>Important: </b> It is not always possible to determine if the message is a redelivery 506 * or not, and therefore <tt>null</tt> is returned. Such an example would be a JDBC message. 507 * However JMS brokers provides details if a message is redelivered. 508 * 509 * @return <tt>true</tt> if redelivered, <tt>false</tt> if not, <tt>null</tt> if not able to determine 510 */ 511 Boolean isExternalRedelivered(); 512 513 /** 514 * Returns true if this exchange is marked for rollback 515 */ 516 boolean isRollbackOnly(); 517 518 /** 519 * Returns the container so that a processor can resolve endpoints from URIs 520 * 521 * @return the container which owns this exchange 522 */ 523 CamelContext getContext(); 524 525 /** 526 * Creates a copy of the current message exchange so that it can be 527 * forwarded to another destination 528 * <p/> 529 * Notice this operation invokes <tt>copy(false)</tt> 530 */ 531 Exchange copy(); 532 533 /** 534 * Creates a copy of the current message exchange so that it can be 535 * forwarded to another destination 536 * 537 * @param safeCopy whether to copy exchange properties and message headers safely to a new map instance, 538 * or allow sharing the same map instances in the returned copy. 539 */ 540 Exchange copy(boolean safeCopy); 541 542 /** 543 * Returns the endpoint which originated this message exchange if a consumer on an endpoint 544 * created the message exchange, otherwise this property will be <tt>null</tt> 545 */ 546 Endpoint getFromEndpoint(); 547 548 /** 549 * Sets the endpoint which originated this message exchange. This method 550 * should typically only be called by {@link org.apache.camel.Endpoint} implementations 551 * 552 * @param fromEndpoint the endpoint which is originating this message exchange 553 */ 554 void setFromEndpoint(Endpoint fromEndpoint); 555 556 /** 557 * Returns the route id which originated this message exchange if a route consumer on an endpoint 558 * created the message exchange, otherwise this property will be <tt>null</tt> 559 */ 560 String getFromRouteId(); 561 562 /** 563 * Sets the route id which originated this message exchange. This method 564 * should typically only be called by the internal framework. 565 * 566 * @param fromRouteId the from route id 567 */ 568 void setFromRouteId(String fromRouteId); 569 570 /** 571 * Returns the unit of work that this exchange belongs to; which may map to 572 * zero, one or more physical transactions 573 */ 574 UnitOfWork getUnitOfWork(); 575 576 /** 577 * Sets the unit of work that this exchange belongs to; which may map to 578 * zero, one or more physical transactions 579 */ 580 void setUnitOfWork(UnitOfWork unitOfWork); 581 582 /** 583 * Returns the exchange id (unique) 584 */ 585 String getExchangeId(); 586 587 /** 588 * Set the exchange id 589 */ 590 void setExchangeId(String id); 591 592 /** 593 * Adds a {@link org.apache.camel.spi.Synchronization} to be invoked as callback when 594 * this exchange is completed. 595 * 596 * @param onCompletion the callback to invoke on completion of this exchange 597 */ 598 void addOnCompletion(Synchronization onCompletion); 599 600 /** 601 * Checks if the passed {@link org.apache.camel.spi.Synchronization} instance is 602 * already contained on this exchange. 603 * 604 * @param onCompletion the callback instance that is being checked for 605 * @return <tt>true</tt>, if callback instance is already contained on this exchange, else <tt>false</tt> 606 */ 607 boolean containsOnCompletion(Synchronization onCompletion); 608 609 /** 610 * Handover all the on completions from this exchange to the target exchange. 611 * 612 * @param target the target exchange 613 */ 614 void handoverCompletions(Exchange target); 615 616 /** 617 * Handover all the on completions from this exchange 618 * 619 * @return the on completions 620 */ 621 List<Synchronization> handoverCompletions(); 622 623 /** 624 * Gets the timestamp when this exchange was created. 625 */ 626 Date getCreated(); 627 628}