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.Exchange;
020    
021    /**
022     * To allow unit of work for the {@link UnitOfWork} while processing a number of {@link Exchange}s.
023     * <p/>
024     * A sub unit of work is a way of implement sub-transactions in Camel routing.
025     * This is needed by some EIPs where you can have sub routes such as the Splitter.
026     * The Camel end user may want to indicate that the Splitter should act as a
027     * <b>single combined</b> unit of work.
028     * <p/>
029     * To implement this, we use this {@link SubUnitOfWorkCallback}
030     * which allows us to have the sub routes participate in a {@link SubUnitOfWork}
031     * And then the outcome of the {@link SubUnitOfWork} will be a single atomic commit or rollback.
032     * <p/>
033     * When using a {@link SubUnitOfWork} we need to tap into the sub routes, and ensure they callback with the progress
034     * of the sub {@link Exchange} being processed. For example the error handler, we need to tap into, and
035     * ensure that any exhausted sub {@link Exchange} is propagated into the result of the {@link SubUnitOfWork}.
036     * This {@link SubUnitOfWorkCallback} allows us to do that.
037     *
038     * @see SubUnitOfWork
039     */
040    public interface SubUnitOfWorkCallback {
041    
042        /**
043         * The exchange is exhausted, by a redeliverable error handler.
044         *
045         * @param exchange the exchange
046         */
047        void onExhausted(Exchange exchange);
048    
049        /**
050         * The exchange is done.
051         *
052         * @param exchange the exchange.
053         */
054        void onDone(Exchange exchange);
055    
056    }