websphereibm-mqjythonwebsphere-8wsadmin

How to read MQ base queue name using wsadmin script?


I want to read bas queue names inside the queues, have written code but which only able to read the last queue name instead of all.

Below is a code

queueList = AdminConfig.list('MQQueue', AdminConfig.getid('/Cell:' + AdminControl.getCell() + '/')).splitlines()


for queue in queueList:

           print "\t" + queue +"in QueueList"

queueName = AdminConfig.showAttribute(queue, 'baseQueueName')

print queueName

The queue is reading only the last queue name from queueList, I want it to read all the base queue names present inside queues.


Solution

  • Your script as currently written will only execute the following line for each queue in the queueList:

    print "\t" + queue +"in QueueList"
    

    You need to indent the last 2 lines to make them part of the for loop, otherwise they are only executed once after the loop is finished, at that point queue will have the value of the last queue.

    queueList = AdminConfig.list('MQQueue', AdminConfig.getid('/Cell:' + AdminControl.getCell() + '/')).splitlines()
    
    
    for queue in queueList:
    
               print "\t" + queue +"in QueueList"
    
               queueName = AdminConfig.showAttribute(queue, 'baseQueueName')
    
               print queueName