WebSphere7SIB队列:如何从Java访问队列深度?

WebSphere7SIB队列:如何从Java访问队列深度?,java,websphere,mq,Java,Websphere,Mq,我已经创建了一些代码来访问WebSphereMQ的队列深度,但是我无法确定是否有用于访问SIB队列的API,或者是否可以设置Websphere以允许我访问它 有人能给我一些提示/想法吗 谢谢 杰夫·波特(Jeff Porter)对于那些关心的人来说,答案是肥皂 好的,我还没有设法让WSADMIN使用的API工作,但是我已经使用SOAP直接进入websphere来询问它关于队列的情况 注意:默认端口为8880 import java.util.Iterator; import java.util.

我已经创建了一些代码来访问WebSphereMQ的队列深度,但是我无法确定是否有用于访问SIB队列的API,或者是否可以设置Websphere以允许我访问它

有人能给我一些提示/想法吗

谢谢
杰夫·波特(Jeff Porter)

对于那些关心的人来说,答案是肥皂

好的,我还没有设法让WSADMIN使用的API工作,但是我已经使用SOAP直接进入websphere来询问它关于队列的情况

注意:默认端口为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); 
    }  
import java.util.Iterator;
导入java.util.Map;
导入java.util.Properties;
导入java.util.Set;
导入java.util.TreeMap;
导入javax.management.ObjectName;
导入org.apache.log4j.Logger;
导入com.ibm.websphere.management.AdminClient;
导入com.ibm.websphere.management.AdminClientFactory;
Properties connectProps=新属性();
connectProps.setProperty(AdminClient.CONNECTOR\u-TYPE,AdminClient.CONNECTOR\u-TYPE\u-SOAP);
connectProps.setProperty(AdminClient.CONNECTOR_HOST,“127.0.0.1”);
connectProps.setProperty(AdminClient.CONNECTOR_PORT,“8880”);
AdminClient AdminClient=null;
尝试
{
adminClient=AdminClientFactory.createAdminClient(connectProps);
Set s2=adminClient.queryNames(新对象名(“WebSphere:*”),null);
如果(!s2.isEmpty())
{
迭代器i=s2.Iterator();
while(i.hasNext())
{
ObjectName on=i.next();
字符串类型=on.getKeyProperty(“类型”);
如果(“SIBQueuePoint”。等于(类型))
{
字符串queueName=on.getKeyProperty(“名称”);
int currentDepth=((整数)adminClient.getAttribute(在“depth”上)).intValue();
int maxSize=((整数)adminClient.getAttribute(在“highMessageThreshold”上)).intValue();
LOG.info(“查询的SIB队列:队列:[“+queueName+”]Size=[“+currentDepth+”]highMessageThreshold:[“+maxSize+”]”);
}
}
}
否则{
System.out.println(“未找到MBean”);
}
}
捕获(例外e)
{
LOG.error(“查找SIB队列详细信息时出错,消息:”+e.getMessage(),e);
}  

nope的可能重复项,而不是重复项。第一个问题是关于从命令行wsadmin命令获取详细信息,这个问题是关于做同样的事情,但是来自Java代码(通过api调用)@JeffPorter-我在前面的问题中从非WASADMIN的角度回答了您的问题:。此外,您可能希望停止将问题命名为相同的问题。如果你没有得到你想要的答案,请在这个问题上悬赏,或者在评论中告诉人们你没有得到你想要的。好的,我明白了。不幸的是,没有取消接近投票的选择。然而,鉴于你在这里的评论,可能不会收到额外的接近票数。要是我能多了解一点,我就好回答这个问题了。