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