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 */
017 package org.apache.camel.spi;
018
019 import java.util.Set;
020
021 import org.apache.camel.CamelContext;
022 import org.apache.camel.Exchange;
023
024 /**
025 * Access to a repository to store aggregated exchanges to support pluggable implementations.
026 *
027 * @version
028 */
029 public interface AggregationRepository {
030
031 /**
032 * Add the given {@link Exchange} under the correlation key.
033 * <p/>
034 * Will replace any existing exchange.
035 *
036 * @param camelContext the current CamelContext
037 * @param key the correlation key
038 * @param exchange the aggregated exchange
039 * @return the old exchange if any existed
040 */
041 Exchange add(CamelContext camelContext, String key, Exchange exchange);
042
043 /**
044 * Gets the given exchange with the correlation key
045 *
046 * @param camelContext the current CamelContext
047 * @param key the correlation key
048 * @return the exchange, or <tt>null</tt> if no exchange was previously added
049 */
050 Exchange get(CamelContext camelContext, String key);
051
052 /**
053 * Removes the exchange with the given correlation key, which should happen
054 * when an {@link Exchange} is completed
055 *
056 * @param camelContext the current CamelContext
057 * @param key the correlation key
058 * @param exchange the exchange to remove
059 */
060 void remove(CamelContext camelContext, String key, Exchange exchange);
061
062 /**
063 * Confirms the completion of the {@link Exchange}.
064 *
065 * @param camelContext the current CamelContext
066 * @param exchangeId exchange id to confirm
067 */
068 void confirm(CamelContext camelContext, String exchangeId);
069
070 /**
071 * Gets the keys currently in the repository.
072 *
073 * @return the keys
074 */
075 Set<String> getKeys();
076
077 }