简体   繁体   English

如何从Weblogic的资源摘要表中获取特定集群的JMS队列列表?

[英]How to get the list of jms queues from Summary of Resources table in weblogic for a certain cluster?

JMXServiceURL serviceURL = new JMXServiceURL("t3", hostname, port, "/jndi/" + DomainRuntimeServiceMBean.MBEANSERVER_JNDI_NAME);
Hashtable h = new Hashtable();
h.put(Context.SECURITY_PRINCIPAL, username);
h.put(Context.SECURITY_CREDENTIALS, password);
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote");
MBeanServerConnection bco = JMXConnectorFactory.connect(serviceURL, h).getMBeanServerConnection();

DomainRuntimeServiceMBean domainRuntimeServiceMBean = (DomainRuntimeServiceMBean) MBeanServerInvocationHandler.newProxyInstance(bco, new ObjectName(DomainRuntimeServiceMBean.OBJECT_NAME));        
DomainMBean dem = domainRuntimeServiceMBean.getDomainConfiguration();
JMSSystemResourceMBean[] jmsSRs = dem.getJMSSystemResources();

JMSServerMBean[] jmsSvrs = dem.getJMSServers();
for(JMSServerMBean jmsSvr : jmsSvrs){
  System.out.println("JMS Servername: "+jmsSvr.getName());
}

for(JMSSystemResourceMBean jmsSR : jmsSRs){
  System.err.println(jmsSR.getName());
  QueueBean[] qbeans = jmsSR.getJMSResource().getQueues();
    for(QueueBean qbean : qbeans){
      System.out.println("JNDI NAME: "+qbean.getJNDIName()+" queuename : "+qbean.getName());
    }
}

I use this code to get all queues from weblogic and it works. 我使用此代码从weblogic获取所有队列,并且可以正常工作。 But now I need to get queues of a certain cluster. 但是现在我需要获取某个集群的队列。 I have two of them and each of them has a listening port. 我有两个,每个都有一个监听端口。 But putting the port in this code above does not work. 但是将端口放在上面的代码中不起作用。 How to accomplish this? 如何做到这一点?

For each JMS Server, you can check to see what it is targeted to and then only print out the queues for it. 对于每个JMS服务器,您可以检查以了解其目标 ,然后仅打印出它的队列。 Something like: 就像是:

JMSServerMBean[] jmsSvrs = dem.getJMSServers();

for(JMSServerMBean jmsSvr : jmsSvrs){
   System.out.println("JMS Servername: "+jmsSvr.getName());

   TargetMBean[] targets = jmsSvr.getTargets()
   for(TargetMBean target : targets)
   {
      if ( target.getName() == "cluster you care about")
      {
          JMSQueueMBean[] queues = jmsSvr.getJMSQueues();
          ...
      }
   }
 }

You can look up all of the available API call in the docs here , so you can explore a little before asking another question. 您可以在此处文档中查找所有可用的API调用,因此可以在询问另一个问题之前先进行一些探索。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM