简体   繁体   中英

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.

Can anyone give me some hints/ideas?

Thanks Jeff Porter

The answer, for those that care is 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.

Note: Default port is 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); 
    }  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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