[英]How to get the list of jms queues from Summary of Resources table in weblogic for a certain cluster?
[英]How to get the list of jms queues from Summary of Resources table of jms module in weblogic?
我需要打印jms模塊的jms隊列列表。 我使用此代碼查找所需的隊列並獲取參數,但是如何獲取所有隊列的名稱並打印它們呢?
Properties env = new Properties();
env.put(Context.PROVIDER_URL, "host:port");
env.put(Context.SECURITY_PRINCIPAL, "username");
env.put(Context.SECURITY_CREDENTIALS, "password");
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
InitialContext ctx = new InitialContext(env);
Destination queue = (Destination) ctx.lookup("jms_queue");
JMSDestinationRuntimeMBean destMBean = JMSRuntimeHelper.getJMSDestinationRuntimeMBean(ctx, queue);
out.println("count: " + destMBean.getMessagesCurrentCount());
在Java中(通過JMX)它將是:
import weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean;
...
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());
}
}
這里的例子
我曾經使用WLST腳本顯示Weblogic域中的所有JMS隊列。 可能您可以嘗試類似的方法:
connect('AdminUser', 'AdminPW', 't3://AdminURL')
easeSyntax()
allJMSResources = cmo.getJMSSystemResources()
for jmsResource in allJMSResources:
module = jmsResource.getName()
print "MODULE", module
QList = jmsResource.getJMSResource().getUniformDistributedQueues()
for queue in QList:
print "QUEUE", queue.getName(), " JNDINAME", queue.getJNDIName()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.