【问题标题】:How to get the list of jms queues from Summary of Resources table of jms module in weblogic?如何从 weblogic 中 jms 模块的资源摘要表中获取 jms 队列列表?
【发布时间】:2014-09-21 16:38:40
【问题描述】:

我需要打印 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 jsp weblogic


    【解决方案1】:

    在 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());
        }
    }
    

    来自here的示例

    【讨论】:

    • 非常感谢。这正是我所需要的。
    【解决方案2】:

    我曾经使用 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()
    

    【讨论】:

    • 非常感谢您的回复。但我需要java中的解决方案。
    猜你喜欢
    • 2021-10-16
    • 1970-01-01
    • 1970-01-01
    • 2013-10-18
    • 1970-01-01
    • 2015-04-02
    • 2011-01-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多