2015-02-04 2 views
1

я подключиться к удаленному был с 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");) 
      } 
    } 
} 

Этот список мне очередей с провайдером JMS «провайдера обмена сообщениями по умолчанию». Но также, у меня есть несколько очередей с «провайдером сообщений Websphere MQ», которые не существуют в этом списке.

Как я могу получить список со всеми очередями от всех поставщиков JMS?

+0

Позвольте мне понять, что вам нужно. Вы хотите экспортировать очереди и очереди очередей? Или вам нужны все из них, включая фабрики Connetion, фабрики подключения темы, темы и спецификацию активации? – adimoise91

+0

@ adimoise91 только очереди и очереди очереди. – vicvtor

+0

У вас есть доступ к командам wsadmin? Если у вас есть, вы можете использовать некоторые встроенные функции. Так скажите мне, можете ли вы использовать команды wsadmin, потому что я должен знать, как написать сценарий для вас. Я не знаю, как написать скрипт на языке Java. Но если вы хотите, я могу сделать скрипт в python для вас, а затем, если вы поймете, как решить вашу проблему, вы можете попробовать этот метод в Java-языке. Я жду Вашего ответа. – adimoise91

ответ

0

Счастье в последнее время. Как я и обещаю, вот сценарий на языке python.

Все, что вам нужно сделать, это заменить область действия и файл ресурсов.

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() 

Удачи!

Смежные вопросы