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.activemq.broker.region.policy;
018    
019    
020    import org.apache.activemq.Service;
021    import org.apache.activemq.broker.ConnectionContext;
022    import org.apache.activemq.broker.region.MessageReference;
023    import org.apache.activemq.broker.region.SubscriptionRecovery;
024    import org.apache.activemq.broker.region.Topic;
025    import org.apache.activemq.command.ActiveMQDestination;
026    import org.apache.activemq.command.Message;
027    
028    /**
029     * Abstraction to allow different recovery policies to be plugged
030     * into the region implementations.  This is used by a topic to retroactively recover
031     * messages that the subscription missed.
032     * 
033     * @version $Revision$
034     */
035    public interface SubscriptionRecoveryPolicy extends Service {
036        
037        /**
038         * A message was sent to the destination.
039         * 
040         * @param context
041         * @param message 
042         * @param node
043         * @return true if successful
044         * @throws Exception
045         */
046        boolean add(ConnectionContext context, MessageReference message) throws Exception;
047        
048        /**
049         * Let a subscription recover message held by the policy.
050         * 
051         * @param context
052         * @param topic
053         * @param sub 
054         * @param node
055         * @throws Exception
056         */
057        void recover(ConnectionContext context, Topic topic, SubscriptionRecovery sub) throws Exception;
058        
059        
060        /**
061         * @param dest 
062         * @return messages
063         * @throws Exception 
064         */
065        Message[] browse(ActiveMQDestination dest) throws Exception;
066    
067        /**
068         * Used to copy the policy object.
069         * @return the copy
070         */
071        SubscriptionRecoveryPolicy copy();
072    }