Save This Page
Home » activemq-parent-5.3.1-source-release » org.apache » activemq » broker » region » policy » [javadoc | source]
    1   /**
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.activemq.broker.region.policy;
   18   
   19   import org.apache.activemq.command.ActiveMQDestination;
   20   import org.apache.activemq.command.ActiveMQQueue;
   21   import org.apache.activemq.command.ActiveMQTopic;
   22   
   23   /**
   24    * A {@link DeadLetterStrategy} where each destination has its own individual
   25    * DLQ using the subject naming hierarchy.
   26    * 
   27    * @org.apache.xbean.XBean
   28    * @version $Revision: 564057 $
   29    */
   30   public class IndividualDeadLetterStrategy extends AbstractDeadLetterStrategy {
   31   
   32       private String topicPrefix = "ActiveMQ.DLQ.Topic.";
   33       private String queuePrefix = "ActiveMQ.DLQ.Queue.";
   34       private boolean useQueueForQueueMessages = true;
   35       private boolean useQueueForTopicMessages = true;
   36   
   37       public ActiveMQDestination getDeadLetterQueueFor(ActiveMQDestination originalDestination) {
   38           if (originalDestination.isQueue()) {
   39               return createDestination(originalDestination, queuePrefix, useQueueForQueueMessages);
   40           } else {
   41               return createDestination(originalDestination, topicPrefix, useQueueForTopicMessages);
   42           }
   43       }
   44   
   45       // Properties
   46       // -------------------------------------------------------------------------
   47   
   48       public String getQueuePrefix() {
   49           return queuePrefix;
   50       }
   51   
   52       /**
   53        * Sets the prefix to use for all dead letter queues for queue messages
   54        */
   55       public void setQueuePrefix(String queuePrefix) {
   56           this.queuePrefix = queuePrefix;
   57       }
   58   
   59       public String getTopicPrefix() {
   60           return topicPrefix;
   61       }
   62   
   63       /**
   64        * Sets the prefix to use for all dead letter queues for topic messages
   65        */
   66       public void setTopicPrefix(String topicPrefix) {
   67           this.topicPrefix = topicPrefix;
   68       }
   69   
   70       public boolean isUseQueueForQueueMessages() {
   71           return useQueueForQueueMessages;
   72       }
   73   
   74       /**
   75        * Sets whether a queue or topic should be used for queue messages sent to a
   76        * DLQ. The default is to use a Queue
   77        */
   78       public void setUseQueueForQueueMessages(boolean useQueueForQueueMessages) {
   79           this.useQueueForQueueMessages = useQueueForQueueMessages;
   80       }
   81   
   82       public boolean isUseQueueForTopicMessages() {
   83           return useQueueForTopicMessages;
   84       }
   85   
   86       /**
   87        * Sets whether a queue or topic should be used for topic messages sent to a
   88        * DLQ. The default is to use a Queue
   89        */
   90       public void setUseQueueForTopicMessages(boolean useQueueForTopicMessages) {
   91           this.useQueueForTopicMessages = useQueueForTopicMessages;
   92       }
   93   
   94       // Implementation methods
   95       // -------------------------------------------------------------------------
   96       protected ActiveMQDestination createDestination(ActiveMQDestination originalDestination, String prefix, boolean useQueue) {
   97           String name = prefix + originalDestination.getPhysicalName();
   98           if (useQueue) {
   99               return new ActiveMQQueue(name);
  100           } else {
  101               return new ActiveMQTopic(name);
  102           }
  103       }
  104   
  105   }

Save This Page
Home » activemq-parent-5.3.1-source-release » org.apache » activemq » broker » region » policy » [javadoc | source]