[jboss-user] [Messaging, JMS & JBossMQ] - Re: import org.jboss.mq.server.jmx.Queue
vitor_b
do-not-reply at jboss.com
Fri Mar 23 08:05:03 EDT 2007
Hello
I have a solution for you. The key is JMX API.
As you know there is a MBean which you can view using jboss jmx console.
One thing we have to do is to acces that MBean. Here is some code i have written for you:
String domain = "jboss.mq.destination";
| String service = "service=Queue";
| String name = "name=testQueue";
|
| String stringObjectName = domain + ":" + service + "," + name;
|
| MBeanServer server = MBeanServerLocator.locateJBoss();
|
| try{
| ObjectName queueObjectName = ObjectName.getInstance(stringObjectName);
|
| org.jboss.mq.server.jmx.QueueMBean queueMBean =
| (org.jboss.mq.server.jmx.QueueMBean) MBeanServerInvocationHandler.newProxyInstance(
| server,
| queueObjectName,
| org.jboss.mq.server.jmx.QueueMBean.class,
| false
| );
|
| logger.info("queue depth: " + queueMBean.getQueueDepth());
|
| }catch (Exception e){
| logger.info("cannot get depth of the queue: " + e.getMessage(),e);
| }
When you have a proxy then you can get all queue properties by calling method: getNameOfAttribute (ex. queueMBean.getQueueDepth();)
These three strings set up at the begining are taken from jmx-console page for MBean monitoring Queue.
If you have any questions, just ask.
As a reward please look at my question (Queue - I can send but cannot receive) i'm going to write right now.
Since you are working with queues maybe you will be able to help me.
Take care
vitor_b
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031029#4031029
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031029
More information about the jboss-user
mailing list