1 /** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one or more 4 * contributor license agreements. See the NOTICE file distributed with 5 * this work for additional information regarding copyright ownership. 6 * The ASF licenses this file to You under the Apache License, Version 2.0 7 * (the "License"); you may not use this file except in compliance with 8 * the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 package org.apache.activemq.broker.region.policy; 19 20 21 import org.apache.activemq.Service; 22 import org.apache.activemq.broker.ConnectionContext; 23 import org.apache.activemq.broker.region.MessageReference; 24 import org.apache.activemq.broker.region.Subscription; 25 import org.apache.activemq.broker.region.SubscriptionRecovery; 26 import org.apache.activemq.broker.region.Topic; 27 import org.apache.activemq.command.ActiveMQDestination; 28 import org.apache.activemq.command.Message; 29 30 /** 31 * Abstraction to allow different recovery policies to be plugged 32 * into the region implementations. This is used by a topic to retroactively recover 33 * messages that the subscription missed. 34 * 35 * @version $Revision$ 36 */ 37 public interface SubscriptionRecoveryPolicy extends Service { 38 39 /** 40 * A message was sent to the destination. 41 * 42 * @param context 43 * @param message 44 * @param node 45 * @return true if successful 46 * @throws Exception 47 */ 48 boolean add(ConnectionContext context, MessageReference message) throws Exception; 49 50 /** 51 * Let a subscription recover message held by the policy. 52 * 53 * @param context 54 * @param topic 55 * @param sub 56 * @param node 57 * @throws Exception 58 */ 59 void recover(ConnectionContext context, Topic topic, SubscriptionRecovery sub) throws Exception; 60 61 62 /** 63 * @param dest 64 * @return messages 65 * @throws Exception 66 */ 67 Message[] browse(ActiveMQDestination dest) throws Exception; 68 69 /** 70 * Used to copy the policy object. 71 * @return the copy 72 */ 73 SubscriptionRecoveryPolicy copy(); 74 } 75