简体   繁体   English

我如何获取包含远程Websphere应用程序服务器中所有队列名称的列表?

[英]How i can get list with names of all queues in remote websphere application server?

I connect to remote was with AdminClient and get list of queues with some code: 我使用AdminClient连接到远程服务器,并使用一些代码获取队列列表:

...
AdminClient client = new AdminClientFactory.createAdminClient(props);
Set<ObjectName> s = client.queryNames(new ObjectName("WebSphere:*"),null);
if (!s.isEmpty()){
     Iterator i = s.iterator();
     while (i.hasNext){
          ObjectName on = i.next();
          String type = on.getKeyProperty("type");
          if ("SIBQueuePoint".eqquals(type)){
               System.out.println(on.getKeyProperty("name");)
          }
     }
}

This list me queues with JMS provider "Default Messaging provider". 该列表与JMS提供程序“ Default Messaging provider”一起排队。 But also, i have some queues with "Websphere MQ messaging provider", which not exist in this list. 而且,我还有一些“ Websphere MQ消息传递提供程序”队列,在此列表中不存在。

How i can get list with all queues from all JMS providers? 我如何从所有JMS提供程序获取所有队列的列表?

Srry for late. 抱歉,迟到了。 As i promise, here is the script in python language. 我保证,这是python语言的脚本。

All you have to do is to replace your scope and your resource file. 您要做的就是替换您的范围和您的资源文件。

import sys, java, java.io, java.lang

lineSeparator = java.lang.System.getProperty('line.separator')

def listMQQCF(scope):
    scopeID = AdminConfig.getid(scope)
    scopeName = scope[scope.rfind(":")+1:scope.rfind("/")]
    wmqQCFList = AdminConfig.list('MQQueueConnectionFactory', scopeID).split(lineSeparator)
    MQQCFListHeader = "\n#==== MQQueueConnectionFactoryList " + scopeName + " ===="
    MQQCFListHeader = MQQCFListHeader + "\n#[name, jndiName, ,description, queueManager, transportType, host, port, channel, ConmaxConn, ConminCon, SessionmaxConn, SessionminConn]\n"  
    MQQCFList = "MQQueueConnectionFactoryList = [\\\n"
    if (len(wmqQCFList) > 0):
        for wmqQCF in wmqQCFList:
            wmqQCFName = wmqQCF[wmqQCF.rfind("/")+1:wmqQCF.find("|")]
            if (scopeName == wmqQCFName):
                name = AdminConfig.showAttribute(wmqQCF, 'name')
                jndiName = AdminConfig.showAttribute(wmqQCF, 'jndiName')
                description = AdminConfig.showAttribute(wmqQCF, 'description')
                if (description == None): description = ""
                queueManager = AdminConfig.showAttribute(wmqQCF, 'queueManager')                
                transportType = AdminConfig.showAttribute(wmqQCF, 'transportType')
                host = AdminConfig.showAttribute(wmqQCF, 'host')
                port = AdminConfig.showAttribute(wmqQCF, 'port')
                channel = AdminConfig.showAttribute(wmqQCF, 'channel')
                connPool = AdminConfig.showAttribute(wmqQCF, 'connectionPool')
                sessionPool = AdminConfig.showAttribute(wmqQCF, 'sessionPool')
                connTimeout = AdminConfig.showAttribute(connPool, "connectionTimeout")
                maxConn = AdminConfig.showAttribute(connPool, "maxConnections")
                minConn = AdminConfig.showAttribute(connPool, "minConnections")
                reapTime = AdminConfig.showAttribute(connPool, "reapTime")
                unusedTimeout =  AdminConfig.showAttribute(connPool, "unusedTimeout")
                agedTimeout = AdminConfig.showAttribute(connPool, "agedTimeout")
                sesconnTimeout = AdminConfig.showAttribute(sessionPool, "connectionTimeout")
                sesmaxConn = AdminConfig.showAttribute(sessionPool, "maxConnections")
                sesminConn = AdminConfig.showAttribute(sessionPool, "minConnections")
                sesreapTime = AdminConfig.showAttribute(sessionPool, "reapTime")
                sesunusedTimeout =  AdminConfig.showAttribute(sessionPool, "unusedTimeout")
                sesagedTimeout = AdminConfig.showAttribute(sessionPool, "agedTimeout")
                MQQCFList = MQQCFList + "['" + name + "','" + jndiName + "','" + description + "','" +  queueManager + "','" + transportType + "','" + host + "','" + port + "','" + channel + "','" + maxConn + "','" + minConn + "','" + sesmaxConn + "','" + sesminConn + "'],\\\n"
    if (MQQCFList[len(MQQCFList)-3] == ","):
        MQQCFList = MQQCFList[0:len(MQQCFList)-3] + "]\n"
    else:
        MQQCFList = MQQCFList[0:len(MQQCFList)-2] + "]\n"
    return MQQCFListHeader + MQQCFList

def listMQQueue(scope):
    scopeID = AdminConfig.getid(scope)
    scopeName = scope[scope.rfind(":")+1:scope.rfind("/")]
    objdmgr = AdminControl.queryNames('WebSphere:type=Server,name=dmgr,*')
    version = objdmgr[objdmgr.find("version")+8:]
    wmqQueueList = AdminConfig.list('MQQueue', scopeID).split(lineSeparator)
    MQQueueListHeader = "\n#==== MQQueueList " + scopeName + "  ====\n#[name, jndiName, description, baseQueueName, baseQMgrName, persistence, priority, targetClient, messageBody]\n"
    MQQueueList = "MQQueueList = [\\\n"
    if (len(wmqQueueList) > 0) :
        for wmqQueue in wmqQueueList:
            wmqQueueName = wmqQueue[wmqQueue.rfind("/")+1:wmqQueue.find("|")]
            if (scopeName == wmqQueueName):
                name = AdminConfig.showAttribute(wmqQueue, 'name')
                jndiName = AdminConfig.showAttribute(wmqQueue, 'jndiName')
                description = AdminConfig.showAttribute(wmqQueue, 'description')
                if (description == None):   description = ""
                baseQueueName = AdminConfig.showAttribute(wmqQueue, 'baseQueueName')
                baseQMgrName = AdminConfig.showAttribute(wmqQueue, 'baseQueueManagerName')
                if (baseQMgrName == None):  baseQMgrName = ""
                persistence = AdminConfig.showAttribute(wmqQueue, 'persistence')    
                priority = AdminConfig.showAttribute(wmqQueue, 'priority')
                targetClient = AdminConfig.showAttribute(wmqQueue, 'targetClient')
                if (version =='8'):
                    messageBody = AdminConfig.showAttribute(wmqQueue, 'messageBody')
                else:
                    messageBody = ""                
                MQQueueList = MQQueueList + "['" + name + "','" + jndiName + "','" + description + "','" + baseQueueName + "','" + baseQMgrName + "','" + persistence + "','" + priority + "','" + targetClient + "','" + messageBody + "'],\\\n"               
            #endif
    if (MQQueueList[len(MQQueueList)-3] == ","):
        MQQueueList = MQQueueList[0:len(MQQueueList)-3] + "]\n"
    else:
        MQQueueList = MQQueueList[0:len(MQQueueList)-2] + "]\n"
    return MQQueueListHeader + MQQueueList


#===============================================
#MAIN
#===============================================    

filename='resources.txt'
scope='/Cell:CellName/ServerCluster:ClusterName/'


objItemFileOutputStream = java.io.FileOutputStream(fileName, 1)
scopeID = AdminConfig.getid(scope)
if ( scopeID <> ""):
    list = listRes(objType, scope)
    objItemFileOutputStream.write(list)
else:
    print "\n" + scope + "\t Failed: Incorrect scopes!\n"
objItemFileOutputStream.close()

Good Luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Java应用程序中从远程Websphere应用程序服务器获取正在运行的应用程序列表? - How i can take list of running apps from remote websphere app server in my java app? 如何将安全连接到远程Websphere服务器? - How i can connect secure to remote websphere server? 如何使WebSphere项目在tc服务器下运行? - How can I get a WebSphere project to run under tc server? 如何以客户端的身份获取Stomp队列或主题列表(名称)? - How to get a list of Stomp queues or/and topics (their names) as a client? 是否可以在远程代理上获取队列列表? - Is it possible to get a list of queues on a remote broker? 如何在启动Websphere Application Server 16.0.0.4(WLP)时打开日志记录例外? - How can I turn on logging exceptions on startup of Websphere Application Server 16.0.0.4 (WLP)? 如何在java中使用HTTP url获取远程服务器目录的所有文件名? - how to get all file names of remote server directory using HTTP url in java? 如何获取JVM加载的所有软件包名称的列表 - How do I get a list of all package names loaded by the JVM 如何在 WebSphere Liberty Server 19.0.0.11 中获取应用程序的最后访问时间 - How to get last access time of application in WebSphere Liberty Server 19.0.0.11 如何获取模式的所有表名称? - How can I get all tables names of a schema?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM