Reputation: 47
I need to print the list of jms queues of the jms module. I use this code to look up the needed queue and get parameters but how to get the names of all queues and print them?
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());
Upvotes: 3
Views: 4587
Reputation: 6227
In Java (via JMX) it would be:
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());
}
}
Example from here
Upvotes: 2
Reputation: 395
I once used WLST scripts to display all JMS Queues within a Weblogic Domain. Probably you can try something like:
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()
Upvotes: 1