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; 025import org.apache.camel.spi.annotations.ConstantProvider; 026 027/** 028 * An Exchange is the message container holding the information during the entire routing of 029 * a {@link Message} received by a {@link Consumer}. 030 * <p/> 031 * During processing down the {@link Processor} chain, the {@link Exchange} provides access to the 032 * current (not the original) request and response {@link Message} messages. The {@link Exchange} 033 * also holds meta-data during its entire lifetime stored as properties accessible using the 034 * various {@link #getProperty(String)} methods. The {@link #setProperty(String, Object)} is 035 * used to store a property. For example you can use this to store security, SLA related 036 * data or any other information deemed useful throughout processing. If an {@link Exchange} 037 * failed during routing the {@link Exception} that caused the failure is stored and accessible 038 * via the {@link #getException()} method. 039 * <p/> 040 * An Exchange is created when a {@link Consumer} receives a request. A new {@link Message} is 041 * created, the request is set as the body of the {@link Message} and depending on the {@link Consumer} 042 * other {@link Endpoint} and protocol related information is added as headers on the {@link Message}. 043 * Then an Exchange is created and the newly created {@link Message} is set as the in on the Exchange. 044 * Therefore an Exchange starts its life in a {@link Consumer}. The Exchange is then sent down the 045 * {@link Route} for processing along a {@link Processor} chain. The {@link Processor} as the name 046 * suggests is what processes the {@link Message} in the Exchange and Camel, in addition to 047 * providing out-of-the-box a large number of useful processors, it also allows you to create your own. 048 * The rule Camel uses is to take the out {@link Message} produced by the previous {@link Processor} 049 * and set it as the in for the next {@link Processor}. If the previous {@link Processor} did not 050 * produce an out, then the in of the previous {@link Processor} is sent as the next in. At the 051 * end of the processing chain, depending on the {@link ExchangePattern Message Exchange Pattern} (or MEP) 052 * the last out (or in of no out available) is sent by the {@link Consumer} back to the original caller. 053 * <p/> 054 * Camel, in addition to providing out-of-the-box a large number of useful processors, it also allows 055 * you to implement and use your own. When the Exchange is passed to a {@link Processor}, it always 056 * contains an in {@link Message} and no out {@link Message}. The {@link Processor} <b>may</b> produce 057 * an out, depending on the nature of the {@link Processor}. The in {@link Message} can be accessed 058 * using the {@link #getIn()} method. Since the out message is null when entering the {@link Processor}, 059 * the {@link #getOut()} method is actually a convenient factory method that will lazily instantiate a 060 * {@link org.apache.camel.support.DefaultMessage} which you could populate. As an alternative you could 061 * also instantiate your specialized {@link Message} and set it on the exchange using the 062 * {@link #setOut(org.apache.camel.Message)} method. Please note that a {@link Message} contains not only 063 * the body but also headers and attachments. If you are creating a new {@link Message} the headers and 064 * attachments of the in {@link Message} are not automatically copied to the out by Camel and you'll have 065 * to set the headers and attachments you need yourself. If your {@link Processor} is not producing a 066 * different {@link Message} but only needs to slightly modify the in, you can simply update the in 067 * {@link Message} returned by {@link #getIn()}. 068 * <p/> 069 * See this <a href="http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html">FAQ entry</a> 070 * for more details. 071 */ 072@ConstantProvider("org.apache.camel.ExchangeConstantProvider") 073public interface Exchange { 074 075 String AUTHENTICATION = "CamelAuthentication"; 076 String AUTHENTICATION_FAILURE_POLICY_ID = "CamelAuthenticationFailurePolicyId"; 077 @Deprecated 078 String ACCEPT_CONTENT_TYPE = "CamelAcceptContentType"; 079 String AGGREGATED_SIZE = "CamelAggregatedSize"; 080 String AGGREGATED_TIMEOUT = "CamelAggregatedTimeout"; 081 String AGGREGATED_COMPLETED_BY = "CamelAggregatedCompletedBy"; 082 String AGGREGATED_CORRELATION_KEY = "CamelAggregatedCorrelationKey"; 083 String AGGREGATED_COLLECTION_GUARD = "CamelAggregatedCollectionGuard"; 084 String AGGREGATION_STRATEGY = "CamelAggregationStrategy"; 085 String AGGREGATION_COMPLETE_CURRENT_GROUP = "CamelAggregationCompleteCurrentGroup"; 086 String AGGREGATION_COMPLETE_ALL_GROUPS = "CamelAggregationCompleteAllGroups"; 087 String AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE = "CamelAggregationCompleteAllGroupsInclusive"; 088 String ASYNC_WAIT = "CamelAsyncWait"; 089 090 String BATCH_INDEX = "CamelBatchIndex"; 091 String BATCH_SIZE = "CamelBatchSize"; 092 String BATCH_COMPLETE = "CamelBatchComplete"; 093 String BEAN_METHOD_NAME = "CamelBeanMethodName"; 094 String BINDING = "CamelBinding"; 095 // do not prefix with Camel and use lower-case starting letter as its a shared key 096 // used across other Apache products such as AMQ, SMX etc. 097 String BREADCRUMB_ID = "breadcrumbId"; 098 099 String CHARSET_NAME = "CamelCharsetName"; 100 String CIRCUIT_BREAKER_STATE = "CamelCircuitBreakerState"; 101 String CREATED_TIMESTAMP = "CamelCreatedTimestamp"; 102 String CLAIM_CHECK_REPOSITORY = "CamelClaimCheckRepository"; 103 String CONTENT_ENCODING = "Content-Encoding"; 104 String CONTENT_LENGTH = "Content-Length"; 105 String CONTENT_TYPE = "Content-Type"; 106 String COOKIE_HANDLER = "CamelCookieHandler"; 107 String CORRELATION_ID = "CamelCorrelationId"; 108 109 String DATASET_INDEX = "CamelDataSetIndex"; 110 String DEFAULT_CHARSET_PROPERTY = "org.apache.camel.default.charset"; 111 String DESTINATION_OVERRIDE_URL = "CamelDestinationOverrideUrl"; 112 String DISABLE_HTTP_STREAM_CACHE = "CamelDisableHttpStreamCache"; 113 String DUPLICATE_MESSAGE = "CamelDuplicateMessage"; 114 115 String DOCUMENT_BUILDER_FACTORY = "CamelDocumentBuilderFactory"; 116 117 String EXCEPTION_CAUGHT = "CamelExceptionCaught"; 118 String EXCEPTION_HANDLED = "CamelExceptionHandled"; 119 String EVALUATE_EXPRESSION_RESULT = "CamelEvaluateExpressionResult"; 120 String ERRORHANDLER_CIRCUIT_DETECTED = "CamelFErrorHandlerCircuitDetected"; 121 String ERRORHANDLER_HANDLED = "CamelErrorHandlerHandled"; 122 String EXTERNAL_REDELIVERED = "CamelExternalRedelivered"; 123 124 String FAILURE_HANDLED = "CamelFailureHandled"; 125 String FAILURE_ENDPOINT = "CamelFailureEndpoint"; 126 String FAILURE_ROUTE_ID = "CamelFailureRouteId"; 127 String FATAL_FALLBACK_ERROR_HANDLER = "CamelFatalFallbackErrorHandler"; 128 String FILE_CONTENT_TYPE = "CamelFileContentType"; 129 String FILE_LOCAL_WORK_PATH = "CamelFileLocalWorkPath"; 130 String FILE_NAME = "CamelFileName"; 131 String FILE_NAME_ONLY = "CamelFileNameOnly"; 132 String FILE_NAME_PRODUCED = "CamelFileNameProduced"; 133 String FILE_NAME_CONSUMED = "CamelFileNameConsumed"; 134 String FILE_PATH = "CamelFilePath"; 135 String FILE_PARENT = "CamelFileParent"; 136 String FILE_LAST_MODIFIED = "CamelFileLastModified"; 137 String FILE_LENGTH = "CamelFileLength"; 138 String FILE_LOCK_FILE_ACQUIRED = "CamelFileLockFileAcquired"; 139 String FILE_LOCK_FILE_NAME = "CamelFileLockFileName"; 140 String FILE_LOCK_EXCLUSIVE_LOCK = "CamelFileLockExclusiveLock"; 141 String FILE_LOCK_RANDOM_ACCESS_FILE = "CamelFileLockRandomAccessFile"; 142 String FILE_LOCK_CHANNEL_FILE = "CamelFileLockChannelFile"; 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 String STEP_ID = "CamelStepId"; 228 229 String TIMER_COUNTER = "CamelTimerCounter"; 230 String TIMER_FIRED_TIME = "CamelTimerFiredTime"; 231 String TIMER_NAME = "CamelTimerName"; 232 String TIMER_PERIOD = "CamelTimerPeriod"; 233 String TIMER_TIME = "CamelTimerTime"; 234 String TO_ENDPOINT = "CamelToEndpoint"; 235 String TRACE_EVENT = "CamelTraceEvent"; 236 String TRACE_EVENT_NODE_ID = "CamelTraceEventNodeId"; 237 String TRACE_EVENT_TIMESTAMP = "CamelTraceEventTimestamp"; 238 String TRACE_EVENT_EXCHANGE = "CamelTraceEventExchange"; 239 String TRACING_HEADER_FORMAT = "CamelTracingHeaderFormat"; 240 String TRACING_OUTPUT_FORMAT = "CamelTracingOutputFormat"; 241 String TRY_ROUTE_BLOCK = "TryRouteBlock"; 242 String TRANSFER_ENCODING = "Transfer-Encoding"; 243 244 String UNIT_OF_WORK_EXHAUSTED = "CamelUnitOfWorkExhausted"; 245 246 /** 247 * @deprecated UNIT_OF_WORK_PROCESS_SYNC is not in use and will be removed in future Camel release 248 */ 249 @Deprecated 250 String UNIT_OF_WORK_PROCESS_SYNC = "CamelUnitOfWorkProcessSync"; 251 252 String XSLT_FILE_NAME = "CamelXsltFileName"; 253 String XSLT_ERROR = "CamelXsltError"; 254 String XSLT_FATAL_ERROR = "CamelXsltFatalError"; 255 String XSLT_WARNING = "CamelXsltWarning"; 256 257 /** 258 * Returns the {@link ExchangePattern} (MEP) of this exchange. 259 * 260 * @return the message exchange pattern of this exchange 261 */ 262 ExchangePattern getPattern(); 263 264 /** 265 * Allows the {@link ExchangePattern} (MEP) of this exchange to be customized. 266 * 267 * This typically won't be required as an exchange can be created with a specific MEP 268 * by calling {@link Endpoint#createExchange(ExchangePattern)} but it is here just in case 269 * it is needed. 270 * 271 * @param pattern the pattern 272 */ 273 void setPattern(ExchangePattern pattern); 274 275 /** 276 * Returns a property associated with this exchange by name 277 * 278 * @param name the name of the property 279 * @return the value of the given property or <tt>null</tt> if there is no property for 280 * the given name 281 */ 282 Object getProperty(String name); 283 284 /** 285 * Returns a property associated with this exchange by name 286 * 287 * @param name the name of the property 288 * @param defaultValue the default value to return if property was absent 289 * @return the value of the given property or <tt>defaultValue</tt> if there is no 290 * property for the given name 291 */ 292 Object getProperty(String name, Object defaultValue); 293 294 /** 295 * Returns a property associated with this exchange by name and specifying 296 * the type required 297 * 298 * @param name the name of the property 299 * @param type the type of the property 300 * @return the value of the given property or <tt>null</tt> if there is no property for 301 * the given name or <tt>null</tt> if it cannot be converted to the given type 302 */ 303 <T> T getProperty(String name, Class<T> type); 304 305 /** 306 * Returns a property associated with this exchange by name and specifying 307 * the type required 308 * 309 * @param name the name of the property 310 * @param defaultValue the default value to return if property was absent 311 * @param type the type of the property 312 * @return the value of the given property or <tt>defaultValue</tt> if there is no property for 313 * the given name or <tt>null</tt> if it cannot be converted to the given type 314 */ 315 <T> T getProperty(String name, Object defaultValue, Class<T> type); 316 317 /** 318 * Sets a property on the exchange 319 * 320 * @param name of the property 321 * @param value to associate with the name 322 */ 323 void setProperty(String name, Object value); 324 325 /** 326 * Removes the given property on the exchange 327 * 328 * @param name of the property 329 * @return the old value of the property 330 */ 331 Object removeProperty(String name); 332 333 /** 334 * Remove all of the properties associated with the exchange matching a specific pattern 335 * 336 * @param pattern pattern of names 337 * @return boolean whether any properties matched 338 */ 339 boolean removeProperties(String pattern); 340 341 /** 342 * Removes the properties from this exchange that match the given <tt>pattern</tt>, 343 * except for the ones matching one ore more <tt>excludePatterns</tt> 344 * 345 * @param pattern pattern of names that should be removed 346 * @param excludePatterns one or more pattern of properties names that should be excluded (= preserved) 347 * @return boolean whether any properties matched 348 */ 349 boolean removeProperties(String pattern, String... excludePatterns); 350 351 /** 352 * Returns all of the properties associated with the exchange 353 * 354 * @return all the headers in a Map 355 */ 356 Map<String, Object> getProperties(); 357 358 /** 359 * Returns whether any properties has been set 360 * 361 * @return <tt>true</tt> if any properties has been set 362 */ 363 boolean hasProperties(); 364 365 /** 366 * Returns the inbound request message 367 * 368 * @return the message 369 */ 370 Message getIn(); 371 372 /** 373 * Returns the current message 374 * 375 * @return the current message 376 */ 377 Message getMessage(); 378 379 /** 380 * Returns the current message as the given type 381 * 382 * @param type the given type 383 * @return the message as the given type or <tt>null</tt> if not possible to covert to given type 384 */ 385 <T> T getMessage(Class<T> type); 386 387 /** 388 * Replace the current message instance. 389 * 390 * @param message the new message 391 */ 392 void setMessage(Message message); 393 394 /** 395 * Returns the inbound request message as the given type 396 * 397 * @param type the given type 398 * @return the message as the given type or <tt>null</tt> if not possible to covert to given type 399 */ 400 <T> T getIn(Class<T> type); 401 402 /** 403 * Sets the inbound message instance 404 * 405 * @param in the inbound message 406 */ 407 void setIn(Message in); 408 409 /** 410 * Returns the outbound message, lazily creating one if one has not already 411 * been associated with this exchange. 412 * <p/> 413 * <br/><b>Important:</b> If you want to change the current message, then use {@link #getIn()} instead as it will 414 * ensure headers etc. is kept and propagated when routing continues. Bottom line end users should rarely use 415 * this method. 416 * <p/> 417 * <br/>If you want to test whether an OUT message have been set or not, use the {@link #hasOut()} method. 418 * <p/> 419 * See also the class java doc for this {@link Exchange} for more details and this 420 * <a href="http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html">FAQ entry</a>. 421 * 422 * @return the response 423 * @see #getIn() 424 * @deprecated use {@link #getMessage()} 425 */ 426 @Deprecated 427 Message getOut(); 428 429 /** 430 * Returns the outbound request message as the given type 431 * <p/> 432 * <br/><b>Important:</b> If you want to change the current message, then use {@link #getIn()} instead as it will 433 * ensure headers etc. is kept and propagated when routing continues. Bottom line end users should rarely use 434 * this method. 435 * <p/> 436 * <br/>If you want to test whether an OUT message have been set or not, use the {@link #hasOut()} method. 437 * <p/> 438 * See also the class java doc for this {@link Exchange} for more details and this 439 * <a href="http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html">FAQ entry</a>. 440 * 441 * @param type the given type 442 * @return the message as the given type or <tt>null</tt> if not possible to covert to given type 443 * @see #getIn(Class) 444 * @deprecated use {@link #getMessage(Class)} 445 */ 446 @Deprecated 447 <T> T getOut(Class<T> type); 448 449 /** 450 * Returns whether an OUT message has been set or not. 451 * 452 * @return <tt>true</tt> if an OUT message exists, <tt>false</tt> otherwise. 453 * @deprecated use {@link #getMessage()} 454 */ 455 @Deprecated 456 boolean hasOut(); 457 458 /** 459 * Sets the outbound message 460 * 461 * @param out the outbound message 462 * @deprecated use {@link #setMessage(Message)} 463 */ 464 @Deprecated 465 void setOut(Message out); 466 467 /** 468 * Returns the exception associated with this exchange 469 * 470 * @return the exception (or null if no faults) 471 */ 472 Exception getException(); 473 474 /** 475 * Returns the exception associated with this exchange. 476 * <p/> 477 * Is used to get the caused exception that typically have been wrapped in some sort 478 * of Camel wrapper exception 479 * <p/> 480 * The strategy is to look in the exception hierarchy to find the first given cause that matches the type. 481 * Will start from the bottom (the real cause) and walk upwards. 482 * 483 * @param type the exception type 484 * @return the exception (or <tt>null</tt> if no caused exception matched) 485 */ 486 <T> T getException(Class<T> type); 487 488 /** 489 * Sets the exception associated with this exchange 490 * <p/> 491 * Camel will wrap {@link Throwable} into {@link Exception} type to 492 * accommodate for the {@link #getException()} method returning a plain {@link Exception} type. 493 * 494 * @param t the caused exception 495 */ 496 void setException(Throwable t); 497 498 /** 499 * Returns true if this exchange failed due to either an exception or fault 500 * 501 * @return true if this exchange failed due to either an exception or fault 502 * @see Exchange#getException() 503 */ 504 boolean isFailed(); 505 506 /** 507 * Returns true if this exchange is transacted 508 */ 509 boolean isTransacted(); 510 511 /** 512 * Returns true if this exchange is an external initiated redelivered message (such as a JMS broker). 513 * <p/> 514 * <b>Important: </b> It is not always possible to determine if the message is a redelivery 515 * or not, and therefore <tt>null</tt> is returned. Such an example would be a JDBC message. 516 * However JMS brokers provides details if a message is redelivered. 517 * 518 * @return <tt>true</tt> if redelivered, <tt>false</tt> if not, <tt>null</tt> if not able to determine 519 */ 520 Boolean isExternalRedelivered(); 521 522 /** 523 * Returns true if this exchange is marked for rollback 524 */ 525 boolean isRollbackOnly(); 526 527 /** 528 * Returns the container so that a processor can resolve endpoints from URIs 529 * 530 * @return the container which owns this exchange 531 */ 532 CamelContext getContext(); 533 534 /** 535 * Creates a copy of the current message exchange so that it can be 536 * forwarded to another destination 537 */ 538 Exchange copy(); 539 540 /** 541 * Returns the endpoint which originated this message exchange if a consumer on an endpoint 542 * created the message exchange, otherwise this property will be <tt>null</tt> 543 */ 544 Endpoint getFromEndpoint(); 545 546 /** 547 * Sets the endpoint which originated this message exchange. This method 548 * should typically only be called by {@link org.apache.camel.Endpoint} implementations 549 * 550 * @param fromEndpoint the endpoint which is originating this message exchange 551 */ 552 void setFromEndpoint(Endpoint fromEndpoint); 553 554 /** 555 * Returns the route id which originated this message exchange if a route consumer on an endpoint 556 * created the message exchange, otherwise this property will be <tt>null</tt> 557 */ 558 String getFromRouteId(); 559 560 /** 561 * Sets the route id which originated this message exchange. This method 562 * should typically only be called by the internal framework. 563 * 564 * @param fromRouteId the from route id 565 */ 566 void setFromRouteId(String fromRouteId); 567 568 /** 569 * Returns the unit of work that this exchange belongs to; which may map to 570 * zero, one or more physical transactions 571 */ 572 UnitOfWork getUnitOfWork(); 573 574 /** 575 * Sets the unit of work that this exchange belongs to; which may map to 576 * zero, one or more physical transactions 577 */ 578 void setUnitOfWork(UnitOfWork unitOfWork); 579 580 /** 581 * Returns the exchange id (unique) 582 */ 583 String getExchangeId(); 584 585 /** 586 * Set the exchange id 587 */ 588 void setExchangeId(String id); 589 590 /** 591 * Adds a {@link org.apache.camel.spi.Synchronization} to be invoked as callback when 592 * this exchange is completed. 593 * 594 * @param onCompletion the callback to invoke on completion of this exchange 595 */ 596 void addOnCompletion(Synchronization onCompletion); 597 598 /** 599 * Checks if the passed {@link org.apache.camel.spi.Synchronization} instance is 600 * already contained on this exchange. 601 * 602 * @param onCompletion the callback instance that is being checked for 603 * @return <tt>true</tt>, if callback instance is already contained on this exchange, else <tt>false</tt> 604 */ 605 boolean containsOnCompletion(Synchronization onCompletion); 606 607 /** 608 * Handover all the on completions from this exchange to the target exchange. 609 * 610 * @param target the target exchange 611 */ 612 void handoverCompletions(Exchange target); 613 614 /** 615 * Handover all the on completions from this exchange 616 * 617 * @return the on completions 618 */ 619 List<Synchronization> handoverCompletions(); 620 621 /** 622 * Gets the timestamp when this exchange was created. 623 */ 624 Date getCreated(); 625 626}