001    /** 
002     * 
003     * Copyright 2004 Protique Ltd
004     * 
005     * Licensed under the Apache License, Version 2.0 (the "License"); 
006     * you may not use this file except in compliance with the License. 
007     * 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     **/
018    package org.activemq.service;
019    
020    /**
021     * Represents the redelivery policy which is used when a rollback() occurs
022     * (either JMS or XA). Various options are possible which this policy tries to capture
023     * the main variants.
024     * If enabled, a typical redelivery policy could be to use a back-off timeout period.
025     *
026     * @version $Revision: 1.1.1.1 $
027     */
028    public class RedeliveryPolicy {
029        private int maximumRetryCount = 5;
030        private boolean backOffMode = false;
031        private long initialRedeliveryTimeout = 1000L;
032        private double backOffIncreaseRate = 2.0;
033    
034        /**
035         * Returns whether or not we use a back-off timeout (increasing the timeout
036         * by the {@link #getBackOffIncreaseRate()} each time).
037         */
038        public boolean isBackOffMode() {
039            return backOffMode;
040        }
041    
042        public void setBackOffMode(boolean backOffMode) {
043            this.backOffMode = backOffMode;
044        }
045    
046        /**
047         * Returns the initial redelivery timeout
048         */
049        public long getInitialRedeliveryTimeout() {
050            return initialRedeliveryTimeout;
051        }
052    
053        public void setInitialRedeliveryTimeout(long initialRedeliveryTimeout) {
054            this.initialRedeliveryTimeout = initialRedeliveryTimeout;
055        }
056    
057        /**
058         * Returns the maximum retry count on a single message before its forwarded
059         * to a Dead Letter Queue
060         */
061        public int getMaximumRetryCount() {
062            return maximumRetryCount;
063        }
064    
065        public void setMaximumRetryCount(int maximumRetryCount) {
066            this.maximumRetryCount = maximumRetryCount;
067        }
068    
069        public double getBackOffIncreaseRate() {
070            return backOffIncreaseRate;
071        }
072    
073        public void setBackOffIncreaseRate(double backOffIncreaseRate) {
074            this.backOffIncreaseRate = backOffIncreaseRate;
075        }
076    }