1 18 package org.apache.activemq.broker.region.policy; 19 20 import org.apache.activemq.command.ActiveMQDestination; 21 import org.apache.activemq.command.ActiveMQQueue; 22 import org.apache.activemq.command.ActiveMQTopic; 23 24 32 public class IndividualDeadLetterStrategy implements DeadLetterStrategy { 33 34 private String topicPrefix = "ActiveMQ.DLQ.Topic."; 35 private String queuePrefix = "ActiveMQ.DLQ.Queue."; 36 private boolean useQueueForQueueMessages = true; 37 private boolean useQueueForTopicMessages = true; 38 39 public ActiveMQDestination getDeadLetterQueueFor(ActiveMQDestination originalDestination) { 40 if (originalDestination.isQueue()) { 41 return createDestination(originalDestination, queuePrefix, useQueueForQueueMessages); 42 } 43 else { 44 return createDestination(originalDestination, topicPrefix, useQueueForTopicMessages); 45 } 46 } 47 48 51 public String getQueuePrefix() { 52 return queuePrefix; 53 } 54 55 58 public void setQueuePrefix(String queuePrefix) { 59 this.queuePrefix = queuePrefix; 60 } 61 62 public String getTopicPrefix() { 63 return topicPrefix; 64 } 65 66 69 public void setTopicPrefix(String topicPrefix) { 70 this.topicPrefix = topicPrefix; 71 } 72 73 public boolean isUseQueueForQueueMessages() { 74 return useQueueForQueueMessages; 75 } 76 77 81 public void setUseQueueForQueueMessages(boolean useQueueForQueueMessages) { 82 this.useQueueForQueueMessages = useQueueForQueueMessages; 83 } 84 85 public boolean isUseQueueForTopicMessages() { 86 return useQueueForTopicMessages; 87 } 88 89 93 public void setUseQueueForTopicMessages(boolean useQueueForTopicMessages) { 94 this.useQueueForTopicMessages = useQueueForTopicMessages; 95 } 96 97 protected ActiveMQDestination createDestination(ActiveMQDestination originalDestination, String prefix, boolean useQueue) { 100 String name = prefix + originalDestination.getPhysicalName(); 101 if (useQueue) { 102 return new ActiveMQQueue(name); 103 } 104 else { 105 return new ActiveMQTopic(name); 106 } 107 } 108 109 } 110 | Popular Tags |