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 */ 017package org.apache.activemq.broker.region.policy; 018 019import org.apache.activemq.broker.region.Subscription; 020import org.apache.activemq.command.ActiveMQDestination; 021import org.apache.activemq.command.Message; 022 023/** 024 * A strategy for choosing which destination is used for dead letter queue messages. 025 * 026 * 027 */ 028public interface DeadLetterStrategy { 029 030 /** 031 * Allow pluggable strategy for deciding if message should be sent to a dead letter queue 032 * for example, you might not want to ignore expired or non-persistent messages 033 * @param message 034 * @return true if message should be sent to a dead letter queue 035 */ 036 boolean isSendToDeadLetterQueue(Message message); 037 038 /** 039 * Returns the dead letter queue for the given message and subscription. 040 */ 041 ActiveMQDestination getDeadLetterQueueFor(Message message, Subscription subscription); 042 043 /** 044 * @return true if processes expired messages 045 */ 046 public boolean isProcessExpired() ; 047 048 /** 049 * @param processExpired the processExpired to set 050 */ 051 public void setProcessExpired(boolean processExpired); 052 053 /** 054 * @return the processNonPersistent 055 */ 056 public boolean isProcessNonPersistent(); 057 058 /** 059 * @param processNonPersistent the processNonPersistent to set 060 */ 061 public void setProcessNonPersistent(boolean processNonPersistent); 062 063 /** 064 * Allows for a Message that was already processed by a DLQ to be rolled back in case 065 * of a move or a retry of that message, otherwise the Message would be considered a 066 * duplicate if this strategy is doing Message Auditing. 067 * 068 * @param message 069 */ 070 public void rollback(Message message); 071 072 /** 073 * The expiration value to use on messages sent to the DLQ, default 0 074 * @return expiration in milli seconds 075 */ 076 public void setExpiration(long expiration); 077 078 public long getExpiration(); 079 080}