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