[英]Websphere 7 SIB Queue: how to access queue depth from Java?
我已经创建了一些代码来访问Websphere MQ的队列深度,但是无法确定是否存在用于访问SIB队列的API,或者是否可以设置Websphere来允许我访问它。
谁能给我一些提示/想法?
谢谢杰夫·波特
对于那些关心的问题,答案就是SOAP。
好的,因此我没有设法使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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.