1 18 package org.apache.activemq.broker.jmx; 19 20 import org.apache.activemq.broker.region.Subscription; 21 import org.apache.activemq.command.ActiveMQDestination; 22 import org.apache.activemq.command.ConsumerInfo; 23 24 import javax.jms.InvalidSelectorException ; 25 26 27 28 31 public class SubscriptionView implements SubscriptionViewMBean { 32 33 34 protected final Subscription subscription; 35 protected final String clientId; 36 37 38 42 public SubscriptionView(String clientId,Subscription subs){ 43 this.clientId = clientId; 44 this.subscription = subs; 45 } 46 47 50 public String getClientId(){ 51 return clientId; 52 } 53 54 57 public String getConnectionId(){ 58 ConsumerInfo info = getConsumerInfo(); 59 if (info != null){ 60 return info.getConsumerId().getConnectionId(); 61 } 62 return "NOTSET"; 63 } 64 65 68 public long getSessionId(){ 69 ConsumerInfo info = getConsumerInfo(); 70 if (info != null){ 71 return info.getConsumerId().getSessionId(); 72 } 73 return 0; 74 } 75 76 79 public long getSubcriptionId(){ 80 ConsumerInfo info = getConsumerInfo(); 81 if (info != null){ 82 return info.getConsumerId().getValue(); 83 } 84 return 0; 85 } 86 87 90 public String getDestinationName(){ 91 ConsumerInfo info = getConsumerInfo(); 92 if (info != null){ 93 ActiveMQDestination dest = info.getDestination(); 94 return dest.getPhysicalName(); 95 } 96 return "NOTSET"; 97 } 98 99 public String getSelector() { 100 if (subscription != null) { 101 return subscription.getSelector(); 102 } 103 return null; 104 } 105 106 public void setSelector(String selector) throws InvalidSelectorException , UnsupportedOperationException { 107 if (subscription != null) { 108 subscription.setSelector(selector); 109 } 110 else { 111 throw new UnsupportedOperationException ("No subscription object"); 112 } 113 } 114 115 118 public boolean isDestinationQueue(){ 119 ConsumerInfo info = getConsumerInfo(); 120 if (info != null){ 121 ActiveMQDestination dest = info.getDestination(); 122 return dest.isQueue(); 123 } 124 return false; 125 } 126 127 130 public boolean isDestinationTopic(){ 131 ConsumerInfo info = getConsumerInfo(); 132 if (info != null){ 133 ActiveMQDestination dest = info.getDestination(); 134 return dest.isTopic(); 135 } 136 return false; 137 } 138 139 142 public boolean isDestinationTemporary(){ 143 ConsumerInfo info = getConsumerInfo(); 144 if (info != null){ 145 ActiveMQDestination dest = info.getDestination(); 146 return dest.isTemporary(); 147 } 148 return false; 149 } 150 151 154 public boolean isActive(){ 155 return true; 156 } 157 158 162 public void gc(){ 163 if (subscription != null){ 164 subscription.gc(); 165 } 166 } 167 168 171 public boolean isRetroactive() { 172 ConsumerInfo info = getConsumerInfo(); 173 return info != null ? info.isRetroactive() : false; 174 } 175 176 179 public boolean isExclusive() { 180 ConsumerInfo info = getConsumerInfo(); 181 return info != null ? info.isExclusive() : false; 182 } 183 184 185 188 public boolean isDurable() { 189 ConsumerInfo info = getConsumerInfo(); 190 return info != null ? info.isDurable() : false; 191 } 192 193 196 public boolean isNoLocal() { 197 ConsumerInfo info = getConsumerInfo(); 198 return info != null ? info.isNoLocal() : false; 199 } 200 201 202 206 public int getMaximumPendingMessageLimit() { 207 ConsumerInfo info = getConsumerInfo(); 208 return info != null ? info.getMaximumPendingMessageLimit() : 0; 209 } 210 211 214 public byte getPriority() { 215 ConsumerInfo info = getConsumerInfo(); 216 return info != null ? info.getPriority() : 0; 217 } 218 219 222 public String getSubcriptionName() { 223 ConsumerInfo info = getConsumerInfo(); 224 return info != null ? info.getSubscriptionName() : null; 225 } 226 227 230 public int getPendingQueueSize(){ 231 return subscription != null ? subscription.getPendingQueueSize() : 0; 232 } 233 234 237 public int getDispatchedQueueSize(){ 238 return subscription != null ? subscription.getDispatchedQueueSize() : 0; 239 } 240 241 244 public long getDispachedCounter() { 245 return subscription != null ? subscription.getDispatchedCounter() : 0; 246 } 247 248 251 public long getEnqueueCounter() { 252 return subscription != null ? subscription.getEnqueueCounter() : 0; 253 } 254 255 258 public long getDequeueCounter() { 259 return subscription != null ? subscription.getDequeueCounter() : 0; 260 } 261 262 protected ConsumerInfo getConsumerInfo(){ 263 return subscription != null ? subscription.getConsumerInfo() : null; 264 } 265 266 269 public String toString(){ 270 return "SubscriptionView: " + getClientId() + ":" + getConnectionId(); 271 } 272 273 275 public int getPrefetchSize() { 276 return subscription != null ? subscription.getPrefetchSize() : 0; 277 } 278 279 } 280 | Popular Tags |