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.processor.aggregate;
018
019/**
020 * A controller which allows controlling a {@link org.apache.camel.processor.aggregate.AggregateProcessor} from an
021 * external source, such as Java API or JMX. This can be used to force completion of aggregated groups, and more.
022 */
023public interface AggregateController {
024
025    /**
026     * Callback when the aggregate processor is started.
027     *
028     * @param processor the aggregate processor
029     */
030    void onStart(AggregateProcessor processor);
031
032    /**
033     * Callback when the aggregate processor is stopped.
034     *
035     * @param processor the aggregate processor
036     */
037    void onStop(AggregateProcessor processor);
038
039    /**
040     * To force completing a specific group by its key.
041     *
042     * @param key the key
043     * @return <tt>1</tt> if the group was forced completed, <tt>0</tt> if the group does not exists
044     */
045    int forceCompletionOfGroup(String key);
046
047    /**
048     * To force complete of all groups
049     *
050     * @return number of groups that was forced completed
051     */
052    int forceCompletionOfAllGroups();
053
054}