[jboss-user] [Messaging, JMS & JBossMQ] - queue statistics
marcobaroetto
do-not-reply at jboss.com
Thu Feb 7 06:26:27 EST 2008
Hello, I'm new into JMS and JBoss MQ. I wonder if it is possibile to access to a javax.jms.Queue statistics using jboss mq. I found the MessageCounter class into org.jboss.mq.server package but i don't know how to access it starting from a javax.jms.queue.
What i want to do is to check the current number of message in the queue from code without using a QueueBrowser.
Here is my code:
| Properties props = new Properties();
| QueueSession queueSession;
| QueueSender queueSender;
|
| props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
| props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming.client" );
| props.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
| props.setProperty("j2ee.clientName", "MessageClient");
| Context ctx= new InitialContext(props);
|
| QueueConnectionFactory queueConnectionFactory =
| (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
|
| QueueConnection queueConnection =
| queueConnectionFactory.createQueueConnection();
|
| javax.jms.Queue queue = (javax.jms.Queue)ctx.lookup("queue/MyQueue");
|
| queueSession =
| (QueueSession)queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
| queueSender = queueSession.createSender(queue);
|
| queueSender.setDeliveryMode(DeliveryMode.PERSISTENT);
thank you!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4127323#4127323
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4127323
More information about the jboss-user
mailing list