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.lang.annotation.Documented;
020import java.lang.annotation.ElementType;
021import java.lang.annotation.Retention;
022import java.lang.annotation.RetentionPolicy;
023import java.lang.annotation.Target;
024
025/**
026 * Indicates that this method is to be used as a 
027 * <a href="http://camel.apache.org/recipient-list.html">Dynamic Recipient List</a> routing the incoming message
028 * to one or more endpoints.
029 *
030 * When a message {@link org.apache.camel.Exchange} is received from an {@link org.apache.camel.Endpoint} then the
031 * <a href="http://camel.apache.org/bean-integration.html">Bean Integration</a>
032 * mechanism is used to map the incoming {@link org.apache.camel.Message} to the method parameters.
033 *
034 * The return value of the method is then converted to either a {@link java.util.Collection} or array of objects where each
035 * element is converted to an {@link Endpoint} or a {@link String}, or if it is not a collection/array then it is converted
036 * to an {@link Endpoint} or {@link String}.
037 *
038 * Then for each endpoint or URI the message is forwarded a separate copy.
039 */
040@Retention(RetentionPolicy.RUNTIME)
041@Documented
042@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR })
043public @interface RecipientList {
044
045    /**
046     * Delimiter used if the Expression returned multiple endpoints. Can be turned off using the value <tt>false</tt>.
047     * <p/>
048     * The default value is ,
049     */
050    String delimiter() default ",";
051
052    /**
053     * If enabled then sending messages to the recipients occurs concurrently.
054     * Note the caller thread will still wait until all messages has been fully processed, before it continues.
055     * Its only the sending and processing the replies from the recipients which happens concurrently.
056     */
057    boolean parallelProcessing() default false;
058
059    /**
060     * If enabled then the aggregate method on AggregationStrategy can be called concurrently.
061     * Notice that this would require the implementation of AggregationStrategy to be implemented as thread-safe.
062     * By default this is false meaning that Camel synchronizes the call to the aggregate method.
063     * Though in some use-cases this can be used to archive higher performance when the AggregationStrategy is implemented as thread-safe.
064     */
065    boolean parallelAggregate() default false;
066
067    /**
068     * Will now stop further processing if an exception or failure occurred during processing of an
069     * {@link org.apache.camel.Exchange} and the caused exception will be thrown.
070     * <p/>
071     * Will also stop if processing the exchange failed (has a fault message) or an exception
072     * was thrown and handled by the error handler (such as using onException). In all situations
073     * the recipient list will stop further processing. This is the same behavior as in pipeline, which
074     * is used by the routing engine.
075     * <p/>
076     * The default behavior is to <b>not</b> stop but continue processing till the end
077     */
078    boolean stopOnException() default false;
079
080    /**
081     * If enabled, unwind exceptions occurring at aggregation time to the error handler when parallelProcessing is used.
082     * Currently, aggregation time exceptions do not stop the route processing when parallelProcessing is used.
083     * Enabling this option allows to work around this behavior.
084     *
085     * The default value is <code>false</code> for the sake of backward compatibility.
086     */
087    boolean stopOnAggregateException() default false;
088
089    /**
090     * If enabled then Camel will process replies out-of-order, eg in the order they come back.
091     * If disabled, Camel will process replies in the same order as defined by the recipient list.
092     */
093    boolean streaming() default false;
094
095    /**
096     * Whether to ignore the invalidate endpoint exception when try to create a producer with that endpoint
097     */
098    boolean ignoreInvalidEndpoints() default false;
099
100    /**
101     * Sets a reference to the AggregationStrategy to be used to assemble the replies from the recipients, into a single outgoing message from the RecipientList.
102     * By default Camel will use the last reply as the outgoing message. You can also use a POJO as the AggregationStrategy
103     */
104    String strategyRef() default "";
105
106    /**
107     * Refers to a custom Thread Pool to be used for parallel processing.
108     * Notice if you set this option, then parallel processing is automatic implied, and you do not have to enable that option as well.
109     */
110    String executorServiceRef() default "";
111
112    /**
113     * Sets a total timeout specified in millis, when using parallel processing.
114     * If the Recipient List hasn't been able to send and process all replies within the given timeframe,
115     * then the timeout triggers and the Recipient List breaks out and continues.
116     * Notice if you provide a TimeoutAwareAggregationStrategy then the timeout method is invoked before breaking out.
117     * If the timeout is reached with running tasks still remaining, certain tasks for which it is difficult for Camel
118     * to shut down in a graceful manner may continue to run. So use this option with a bit of care.
119     */
120    long timeout() default 0;
121
122    /**
123     * Uses the {@link Processor} when preparing the {@link org.apache.camel.Exchange} to be send.
124     * This can be used to deep-clone messages that should be send, or any custom logic needed before
125     * the exchange is send.
126     */
127    String onPrepareRef() default "";
128
129    /**
130     * Shares the {@link org.apache.camel.spi.UnitOfWork} with the parent and each of the sub messages.
131     * Recipient List will by default not share unit of work between the parent exchange and each recipient exchange.
132     * This means each sub exchange has its own individual unit of work.
133     */
134    @Deprecated
135    boolean shareUnitOfWork() default false;
136}