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