You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by agujral <an...@yahoo.com> on 2011/05/07 00:13:56 UTC

Trying to access activemq statistics not working

Hi All,
          I have enabled statistics plugin in activeMq and then I am running
a java code pasted below
but I dont seem to be getting any statistics data please help:

When I run the below code it hangs waiting for the response:
May 6, 2011 5:11:33 PM org.apache.activemq.broker.BrokerService start
INFO: Using Persistence Adapter:
AMQPersistenceAdapter(activemq-data/localhost)
May 6, 2011 5:11:34 PM org.apache.activemq.store.amq.AMQPersistenceAdapter
start
INFO: AMQStore starting using directory: activemq-data/localhost
May 6, 2011 5:11:34 PM org.apache.activemq.kaha.impl.KahaStore initialize
INFO: Kaha Store using data directory activemq-data/localhost/kr-store/state
May 6, 2011 5:11:34 PM org.apache.activemq.store.amq.AMQPersistenceAdapter
start
INFO: Active data files: [1]
May 6, 2011 5:11:34 PM org.apache.activemq.broker.BrokerService getBroker
INFO: ActiveMQ null JMS Message Broker (localhost) is starting
May 6, 2011 5:11:34 PM org.apache.activemq.broker.BrokerService getBroker
INFO: For help or more information please see: http://activemq.apache.org/
May 6, 2011 5:11:34 PM org.apache.activemq.kaha.impl.KahaStore initialize
INFO: Kaha Store using data directory activemq-data/localhost/kr-store/data
May 6, 2011 5:11:34 PM org.apache.activemq.broker.BrokerService start
INFO: ActiveMQ JMS Message Broker (localhost,
ID:mq02.res.bluekai.com-30625-1304719894086-0:0) started
May 6, 2011 5:11:34 PM org.apache.activemq.broker.TransportConnector start
INFO: Connector vm://localhost Started
May 6, 2011 5:11:34 PM org.apache.activemq.broker.jmx.ManagementContext$1
run
INFO: JMX consoles can connect to
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
Here is the java code I am using:
package com.bluekai.SDT.BrokerStats;
import javax.jms.Connection;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.ActiveMQMessageConsumer;
import java.util.Enumeration;
public class BrokerStats {

public static void main(String[] argv) throws Exception  {

  printBrokerStats();

}

private static void printBrokerStats() throws JMSException {
 ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("vm://localhost");

  //ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("tcp://mq02.res.bluekai.com?broker.persistent=false&broker.useJmx=false");
  Connection connection;
  connection = connectionFactory.createConnection();
  connection.start();
 Session  session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);


 Destination replyTo = session.createTemporaryQueue();
MessageConsumer consumer = session.createConsumer(replyTo);

String queueName = "ActiveMQ.Statistics.Broker";
Destination testQueue = session.createQueue(queueName);
MessageProducer producer = session.createProducer(testQueue);
Message msg = session.createMessage();

msg.setJMSReplyTo(replyTo);
producer.send(msg);


MapMessage reply = (MapMessage) consumer.receive();

for (Enumeration e = reply.getMapNames();e.hasMoreElements();) {
  String name = e.nextElement().toString();
  System.out.println(name + "=" + reply.getObject(name));
 }
 connection.close();
 }
}




--
View this message in context: http://activemq.2283324.n4.nabble.com/Trying-to-access-activemq-statistics-not-working-tp3504459p3504459.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Trying to access activemq statistics not working

Posted by agujral <an...@yahoo.com>.
Actually I am able to get data from the activemq  there was a bug in my code 
Thanks all
Anurag

--
View this message in context: http://activemq.2283324.n4.nabble.com/Trying-to-access-activemq-statistics-not-working-tp3504459p3606495.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Trying to access activemq statistics not working

Posted by agujral <an...@yahoo.com>.
Can you please guide me what the correct way is then so that I dont get this
error.

Thanks
Anurag

--
View this message in context: http://activemq.2283324.n4.nabble.com/Trying-to-access-activemq-statistics-not-working-tp3504459p3604544.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Trying to access activemq statistics not working

Posted by Dejan Bosanac <de...@nighttale.net>.
Hi,

you're using vm transport that will create an embedded broker, and that
broker doesn't have plugin configured.

Regards
-- 
Dejan Bosanac - http://twitter.com/dejanb
-----------------
The experts in open source integration and messaging - http://fusesource.com
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net

Connect at CamelOne <http://camelone.com/> May 24-26

The Open Source Integration Conference



On Sat, May 7, 2011 at 1:13 AM, agujral <an...@yahoo.com> wrote:

> Hi All,
>          I have enabled statistics plugin in activeMq and then I am running
> a java code pasted below
> but I dont seem to be getting any statistics data please help:
>
> When I run the below code it hangs waiting for the response:
> May 6, 2011 5:11:33 PM org.apache.activemq.broker.BrokerService start
> INFO: Using Persistence Adapter:
> AMQPersistenceAdapter(activemq-data/localhost)
> May 6, 2011 5:11:34 PM org.apache.activemq.store.amq.AMQPersistenceAdapter
> start
> INFO: AMQStore starting using directory: activemq-data/localhost
> May 6, 2011 5:11:34 PM org.apache.activemq.kaha.impl.KahaStore initialize
> INFO: Kaha Store using data directory
> activemq-data/localhost/kr-store/state
> May 6, 2011 5:11:34 PM org.apache.activemq.store.amq.AMQPersistenceAdapter
> start
> INFO: Active data files: [1]
> May 6, 2011 5:11:34 PM org.apache.activemq.broker.BrokerService getBroker
> INFO: ActiveMQ null JMS Message Broker (localhost) is starting
> May 6, 2011 5:11:34 PM org.apache.activemq.broker.BrokerService getBroker
> INFO: For help or more information please see: http://activemq.apache.org/
> May 6, 2011 5:11:34 PM org.apache.activemq.kaha.impl.KahaStore initialize
> INFO: Kaha Store using data directory activemq-data/localhost/kr-store/data
> May 6, 2011 5:11:34 PM org.apache.activemq.broker.BrokerService start
> INFO: ActiveMQ JMS Message Broker (localhost,
> ID:mq02.res.bluekai.com-30625-1304719894086-0:0) started
> May 6, 2011 5:11:34 PM org.apache.activemq.broker.TransportConnector start
> INFO: Connector vm://localhost Started
> May 6, 2011 5:11:34 PM org.apache.activemq.broker.jmx.ManagementContext$1
> run
> INFO: JMX consoles can connect to
> service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
> Here is the java code I am using:
> package com.bluekai.SDT.BrokerStats;
> import javax.jms.Connection;
> import javax.jms.Destination;
> import javax.jms.JMSException;
> import javax.jms.MapMessage;
> import javax.jms.Message;
> import javax.jms.MessageConsumer;
> import javax.jms.MessageProducer;
> import javax.jms.Session;
> import org.apache.activemq.ActiveMQConnectionFactory;
> import org.apache.activemq.ActiveMQMessageConsumer;
> import java.util.Enumeration;
> public class BrokerStats {
>
> public static void main(String[] argv) throws Exception  {
>
>  printBrokerStats();
>
> }
>
> private static void printBrokerStats() throws JMSException {
>  ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory("vm://localhost");
>
>  //ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory("tcp://
> mq02.res.bluekai.com?broker.persistent=false&broker.useJmx=false");
>  Connection connection;
>  connection = connectionFactory.createConnection();
>  connection.start();
>  Session  session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
>
>
>  Destination replyTo = session.createTemporaryQueue();
> MessageConsumer consumer = session.createConsumer(replyTo);
>
> String queueName = "ActiveMQ.Statistics.Broker";
> Destination testQueue = session.createQueue(queueName);
> MessageProducer producer = session.createProducer(testQueue);
> Message msg = session.createMessage();
>
> msg.setJMSReplyTo(replyTo);
> producer.send(msg);
>
>
> MapMessage reply = (MapMessage) consumer.receive();
>
> for (Enumeration e = reply.getMapNames();e.hasMoreElements();) {
>  String name = e.nextElement().toString();
>  System.out.println(name + "=" + reply.getObject(name));
>  }
>  connection.close();
>  }
> }
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Trying-to-access-activemq-statistics-not-working-tp3504459p3504459.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>