简体   繁体   English

Websphere 7 SIB队列:如何从Java访问队列深度?

[英]Websphere 7 SIB Queue: how to access queue depth from Java?

I've created some code to access queue depths for a Websphere MQ, but I can't work out if there is an API for accessing a SIB queue, or if I can setup websphere to allow me to access it. 我已经创建了一些代码来访问Websphere MQ的队列深度,但是无法确定是否存在用于访问SIB队列的API,或者是否可以设置Websphere来允许我访问它。

Can anyone give me some hints/ideas? 谁能给我一些提示/想法?

Thanks Jeff Porter 谢谢杰夫·波特

The answer, for those that care is SOAP. 对于那些关心的问题,答案就是SOAP。

Ok, so I've not managed to get the API used by WSADMIN to work, but I've used SOAP direct into websphere to ask it about the queues. 好的,因此我没有设法使WSADMIN使用的API正常工作,但是我已经将SOAP直接用于Websphere来询问队列。

Note: Default port is 8880 注意:默认端口是8880

import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;

import javax.management.ObjectName;

import org.apache.log4j.Logger;

import com.ibm.websphere.management.AdminClient;
import com.ibm.websphere.management.AdminClientFactory;

 <SNIP>
 Properties connectProps = new Properties();
 connectProps.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP);
 connectProps.setProperty(AdminClient.CONNECTOR_HOST, "127.0.0.1");
 connectProps.setProperty(AdminClient.CONNECTOR_PORT, "8880"); 

 AdminClient adminClient = null;
    try
    {
      adminClient = AdminClientFactory.createAdminClient(connectProps);

      Set<ObjectName> s2 = adminClient.queryNames(new ObjectName("WebSphere:*"), null);
      if (!s2.isEmpty())
      {
        Iterator<ObjectName> i = s2.iterator();
        while (i.hasNext())
        {
          ObjectName on = i.next();
          String type = on.getKeyProperty("type");
          if ("SIBQueuePoint".equals(type))
          {
            String queueName = on.getKeyProperty("name") ;
            int currentDepth =  ((Integer) adminClient.getAttribute(on, "depth")).intValue();
            int maxSize =  ((Integer) adminClient.getAttribute(on, "highMessageThreshold")).intValue();

            LOG.info("Queried SIB queue: Queue: [" + queueName + "] Size =[" + currentDepth + "] highMessageThreshold:["+maxSize+"]");
          }
        }
      }
      else {
        System.out.println("MBean was not found");
      }
    }
    catch (Exception e)
    {
      LOG.error("Error finding SIB queue details, message:" + e.getMessage(), e); 
    }  

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

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