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 019import org.apache.camel.Exchange; 020 021/** 022 * A specialized {@link org.apache.camel.processor.aggregate.AggregationStrategy} which enables the aggregator to run 023 * in pre-completion mode. This allows the {@link #preComplete(org.apache.camel.Exchange, org.apache.camel.Exchange)} method 024 * to control the completion. Only completion timeout or interval can also be used; any other completion configuration 025 * is not in use. 026 * <p/> 027 * Using this strategy supports the use-case, where an incoming Exchange has information that may trigger the completion 028 * of the current group. And then use the new incoming Exchange to start a new group thereafter from scratch. 029 */ 030public interface PreCompletionAwareAggregationStrategy extends AggregationStrategy { 031 032 /** 033 * Determines if the aggregation should complete the current group, and start a new group, or the aggregation 034 * should continue using the current group. 035 * 036 * @param oldExchange the oldest exchange (is <tt>null</tt> on first aggregation as we only have the new exchange) 037 * @param newExchange the newest exchange (can be <tt>null</tt> if there was no data possible to acquire) 038 * @return <tt>true</tt> to complete current group and start a new group, or <tt>false</tt> to keep using current 039 */ 040 boolean preComplete(Exchange oldExchange, Exchange newExchange); 041}