mirror of https://github.com/apache/activemq.git
This commit is contained in:
parent
f4e768760f
commit
da3775302c
|
@ -22,6 +22,7 @@ import java.util.Set;
|
|||
|
||||
import javax.jms.JMSException;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.activemq.advisory.AdvisorySupport;
|
||||
import org.apache.activemq.broker.Broker;
|
||||
import org.apache.activemq.broker.BrokerFilter;
|
||||
|
@ -80,6 +81,7 @@ public class StatisticsBroker extends BrokerFilter {
|
|||
* @see org.apache.activemq.broker.BrokerFilter#send(org.apache.activemq.broker.ProducerBrokerExchange,
|
||||
* org.apache.activemq.command.Message)
|
||||
*/
|
||||
@Override
|
||||
public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception {
|
||||
ActiveMQDestination msgDest = messageSend.getDestination();
|
||||
ActiveMQDestination replyTo = messageSend.getReplyTo();
|
||||
|
@ -206,11 +208,13 @@ public class StatisticsBroker extends BrokerFilter {
|
|||
return this.brokerView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
super.start();
|
||||
LOG.info("Starting StatisticsBroker");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
super.stop();
|
||||
}
|
||||
|
@ -249,6 +253,8 @@ public class StatisticsBroker extends BrokerFilter {
|
|||
protected void sendStats(ConnectionContext context, ActiveMQMapMessage msg, ActiveMQDestination replyTo)
|
||||
throws Exception {
|
||||
msg.setPersistent(false);
|
||||
msg.setTimestamp(System.currentTimeMillis());
|
||||
msg.setPriority((byte) javax.jms.Message.DEFAULT_PRIORITY);
|
||||
msg.setType(AdvisorySupport.ADIVSORY_MESSAGE_TYPE);
|
||||
msg.setMessageId(new MessageId(this.advisoryProducerId, this.messageIdGenerator.getNextSequenceId()));
|
||||
msg.setDestination(replyTo);
|
||||
|
|
|
@ -59,6 +59,8 @@ public class BrokerStatisticsPluginTest extends TestCase{
|
|||
MapMessage reply = (MapMessage) consumer.receive(10*1000);
|
||||
assertNotNull(reply);
|
||||
assertTrue(reply.getMapNames().hasMoreElements());
|
||||
assertTrue(reply.getJMSTimestamp() > 0);
|
||||
assertEquals(Message.DEFAULT_PRIORITY, reply.getJMSPriority());
|
||||
/*
|
||||
for (Enumeration e = reply.getMapNames();e.hasMoreElements();) {
|
||||
String name = e.nextElement().toString();
|
||||
|
@ -93,6 +95,8 @@ public class BrokerStatisticsPluginTest extends TestCase{
|
|||
assertNotNull(reply);
|
||||
assertTrue(reply.getMapNames().hasMoreElements());
|
||||
assertEquals(0, reply.getLong("enqueueCount"));
|
||||
assertTrue(reply.getJMSTimestamp() > 0);
|
||||
assertEquals(Message.DEFAULT_PRIORITY, reply.getJMSPriority());
|
||||
}
|
||||
|
||||
public void testDestinationStats() throws Exception{
|
||||
|
@ -111,6 +115,8 @@ public class BrokerStatisticsPluginTest extends TestCase{
|
|||
MapMessage reply = (MapMessage) consumer.receive();
|
||||
assertNotNull(reply);
|
||||
assertTrue(reply.getMapNames().hasMoreElements());
|
||||
assertTrue(reply.getJMSTimestamp() > 0);
|
||||
assertEquals(Message.DEFAULT_PRIORITY, reply.getJMSPriority());
|
||||
/*
|
||||
for (Enumeration e = reply.getMapNames();e.hasMoreElements();) {
|
||||
String name = e.nextElement().toString();
|
||||
|
@ -137,6 +143,8 @@ public class BrokerStatisticsPluginTest extends TestCase{
|
|||
MapMessage reply = (MapMessage) consumer.receive();
|
||||
assertNotNull(reply);
|
||||
assertTrue(reply.getMapNames().hasMoreElements());
|
||||
assertTrue(reply.getJMSTimestamp() > 0);
|
||||
assertEquals(Message.DEFAULT_PRIORITY, reply.getJMSPriority());
|
||||
|
||||
/*for (Enumeration e = reply.getMapNames();e.hasMoreElements();) {
|
||||
String name = e.nextElement().toString();
|
||||
|
@ -144,6 +152,7 @@ public class BrokerStatisticsPluginTest extends TestCase{
|
|||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
broker = createBroker();
|
||||
ConnectionFactory factory = new ActiveMQConnectionFactory(broker.getTransportConnectorURIsAsMap().get("tcp"));
|
||||
|
@ -151,6 +160,7 @@ public class BrokerStatisticsPluginTest extends TestCase{
|
|||
connection.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception{
|
||||
if (this.connection != null) {
|
||||
this.connection.close();
|
||||
|
|
Loading…
Reference in New Issue