1 17 package org.apache.servicemix.jbi.messaging; 18 19 import org.apache.activemq.management.CountStatisticImpl; 20 import org.apache.activemq.management.StatsImpl; 21 import org.apache.activemq.management.TimeStatisticImpl; 22 import org.apache.activemq.util.IndentPrinter; 23 24 29 public class MessagingStats extends StatsImpl { 30 private String componentName; 31 protected CountStatisticImpl inboundExchanges; 32 protected CountStatisticImpl outboundExchanges; 33 protected TimeStatisticImpl inboundExchangeRate; 34 protected TimeStatisticImpl outboundExchangeRate; 35 36 40 public MessagingStats(String componentName) { 41 this.componentName = componentName; 42 inboundExchanges = new CountStatisticImpl("inboundExchanges", "Number of Inbound MessageExchanges"); 43 outboundExchanges = new CountStatisticImpl("outboundExchanges", "Number of Outbound MessageExchanges"); 44 inboundExchangeRate = new TimeStatisticImpl("inboundExchangeRate", "time taken to process an Exchange"); 45 outboundExchangeRate = new TimeStatisticImpl("outboundExchangeRate", "time taken to send an Exchange"); 46 addStatistic("inboundExchanges", inboundExchanges); 47 addStatistic("outboundExchanges", outboundExchanges); 48 addStatistic("inboundExchangeRate", inboundExchangeRate); 49 addStatistic("outboundExchangeRate", outboundExchangeRate); 50 } 51 52 55 public String getComponentName() { 56 return componentName; 57 } 58 61 public TimeStatisticImpl getInboundExchangeRate() { 62 return inboundExchangeRate; 63 } 64 67 public CountStatisticImpl getInboundExchanges() { 68 return inboundExchanges; 69 } 70 73 public TimeStatisticImpl getOutboundExchangeRate() { 74 return outboundExchangeRate; 75 } 76 79 public CountStatisticImpl getOutboundExchanges() { 80 return outboundExchanges; 81 } 82 83 86 public synchronized void reset() { 87 super.reset(); 88 inboundExchanges.reset(); 89 outboundExchanges.reset(); 90 inboundExchangeRate.reset(); 91 outboundExchangeRate.reset(); 92 } 93 94 97 public String toString() { 98 StringBuffer buffer = new StringBuffer (); 99 buffer.append("Component: "); 100 buffer.append(componentName); 101 buffer.append(" { "); 102 buffer.append(inboundExchanges); 103 buffer.append(" "); 104 buffer.append(inboundExchangeRate); 105 buffer.append(" "); 106 buffer.append(outboundExchanges); 107 buffer.append(" "); 108 buffer.append(outboundExchangeRate); 109 buffer.append(" }"); 110 return buffer.toString(); 111 } 112 113 118 public void dump(IndentPrinter out) { 119 out.printIndent(); 120 out.println("Component: "); 121 out.print(componentName); 122 out.println(" {"); 123 out.incrementIndent(); 124 out.println(inboundExchanges); 125 out.printIndent(); 126 out.println(inboundExchangeRate); 127 out.printIndent(); 128 out.println(outboundExchanges); 129 out.printIndent(); 130 out.decrementIndent(); 131 out.printIndent(); 132 out.println("}"); 133 } 134 135 } | Popular Tags |