On a WebLogic Server, I had to write a WLST script to find the current number of consumers accessing a specific JMS Queue destination as this is not monitored by Oracle Grid Control 11g or Oracle Cloud Control 12c. Knowing only the short name of the queue, I uses a regular expression in my WLST script to find the needed information.

To find the correct queue destination I had to search the Queue Destination Name. But in the Runtime tree, the fully-qualified name of this queue resource is preceded by the parent module name, separated by an exclamation point (!) (e.g DocumentApplicationJMSSystemModule!SOAReqMSQ). So how can I find an object using the short name SOAReqMSQ?

Finding the object via WLST script

To achieve this task, you have to:

Step 1: Use a regular expression by adding in your WLST script:

import re


Step 2: Use the primitive operation:

re.search(pattern, string[, flags])


Step 3: Search only for the defined word and not more:

If you search for SOAReqMSQ using…

result = re.search(cQueueName,destination.getName());
...the result will be:
 To find the correct one, use the $ to match the end of the string
result = re.search(cQueueName,destination.getName());

This way, DocumentApplicationJMSSystemModule!SOAReqMSQ may be found.

Step 4: In the end, your script should look similar to this (the important information related to the search issue is underlined):

import re

# check queue name

# check only the queue for the Managed Server Name containing soa01


# get server list
servers = domainRuntimeService.getServerRuntimes();

if (len(servers) > 0):
for server in servers:
# find if ServerName contains soa01
result = re.search(cServer,server.getName());
if result != None:
jmsRuntime = server.getJMSRuntime();
jmsServers = jmsRuntime.getJMSServers();
jmsName = jmsRuntime.getName();
print 'n';
print 'Name',jmsName;
print '----------------------------';
for jmsServer in jmsServers:
destinations = jmsServer.getDestinations();
for destination in destinations:
result = re.search(cQueueName,destination.getName());
if result != None:
print 'DESTINATION:',destination.getName();
print 'JMS Server:',jmsServer.getName();
print 'ConsumersCurrentCount:',destination.getConsumersCurrentCount()

Step 5: Here is the script output:

Name testdomainsoa01.jms
DESTINATION: DocumentApplicationJMSSystemModule!SOAReqMSQ
JMS Server: DocumentApplicationJMSServer
ConsumersCurrentCount: 0

This python script can be then called by a shell script that will be integrated, for instance, as a UDM script in Grid Control 11g.