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 org.apache.camel.Endpoint;
020 import org.apache.camel.Exchange;
021 import org.apache.camel.Service;
022
023 /**
024 * A repository which tracks in flight {@link Exchange}s.
025 *
026 * @version
027 */
028 public interface InflightRepository extends Service {
029
030 /**
031 * Adds the exchange to the inflight registry to the total counter
032 *
033 * @param exchange the exchange
034 */
035 void add(Exchange exchange);
036
037 /**
038 * Removes the exchange from the inflight registry to the total counter
039 *
040 * @param exchange the exchange
041 */
042 void remove(Exchange exchange);
043
044 /**
045 * Adds the exchange to the inflight registry associated to the given route
046 *
047 * @param exchange the exchange
048 * @param routeId the id of the route
049 */
050 void add(Exchange exchange, String routeId);
051
052 /**
053 * Removes the exchange from the inflight registry removing association to the given route
054 *
055 * @param exchange the exchange
056 * @param routeId the id of the route
057 */
058 void remove(Exchange exchange, String routeId);
059
060 /**
061 * Current size of inflight exchanges.
062 * <p/>
063 * Will return 0 if there are no inflight exchanges.
064 *
065 * @return number of exchanges currently in flight.
066 */
067 int size();
068
069 /**
070 * Will always return 0 due method is deprecated.
071 * @deprecated will be removed in a future Camel release.
072 */
073 @Deprecated
074 int size(Endpoint endpoint);
075
076 /**
077 * Removes the route from the in flight registry.
078 * <p/>
079 * Is used for cleaning up resources to avoid leaking.
080 *
081 * @param routeId the id of the route
082 */
083 void removeRoute(String routeId);
084
085 /**
086 * Current size of inflight exchanges which are from the given route.
087 * <p/>
088 * Will return 0 if there are no inflight exchanges.
089 *
090 * @param routeId the id of the route
091 * @return number of exchanges currently in flight.
092 */
093 int size(String routeId);
094
095 }