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 import org.apache.activemq.command.Message; 020 021 /** 022 * A strategy for choosing which destination is used for dead letter queue 023 * messages. 024 * 025 * @version $Revision: 426366 $ 026 */ 027 public abstract class AbstractDeadLetterStrategy implements DeadLetterStrategy { 028 private boolean processNonPersistent = false; 029 private boolean processExpired = true; 030 031 public boolean isSendToDeadLetterQueue(Message message) { 032 boolean result = false; 033 if (message != null) { 034 result = true; 035 if (!message.isPersistent() && !processNonPersistent) { 036 result = false; 037 } 038 if (message.isExpired() && !processExpired) { 039 result = false; 040 } 041 } 042 return result; 043 } 044 045 /** 046 * @return the processExpired 047 */ 048 public boolean isProcessExpired() { 049 return this.processExpired; 050 } 051 052 /** 053 * @param processExpired the processExpired to set 054 */ 055 public void setProcessExpired(boolean processExpired) { 056 this.processExpired = processExpired; 057 } 058 059 /** 060 * @return the processNonPersistent 061 */ 062 public boolean isProcessNonPersistent() { 063 return this.processNonPersistent; 064 } 065 066 /** 067 * @param processNonPersistent the processNonPersistent to set 068 */ 069 public void setProcessNonPersistent(boolean processNonPersistent) { 070 this.processNonPersistent = processNonPersistent; 071 } 072 073 }