Manipulating JMS queues using WLST Script


Today, let’s talk about Java Message Systems (JMS), the reason led me talk about this, is that my environment, a complex architecture of messages where we have more of two hundred queues in the same domain.
The administration of queues in the weblogic console is very simple, but, if you need to remove a million messages, in a hundred queues, you have a problem!
To turn more agile the visualization of messages, state and other queue properties, nothing better than to use WLST.

This post shows a script, which can grow up where you imagine, for while the script have just three options (the most useful to me) and nothing prevents to have more.

1 – Pause consumer
2 – Resume consumer
3 – Delete messages

You just need to edit the script to add user, password and admin console url.

# @author Dieison Larri santos
# 30/04/2016

print " What do you need?"
print " "
print "1 - Pause Consumer"
print "2 - Resume Consumer"
print "3 - Delete Messages"
task = raw_input("choose an option: ")
task = int(task)

servers = domainRuntimeService.getServerRuntimes();
if (len(servers) > 0):
for server in servers:
jmsRuntime = server.getJMSRuntime();
jmsServers = jmsRuntime.getJMSServers();
for jmsServer in jmsServers:
destinations = jmsServer.getDestinations();
for destination in destinations:
pen = destination.getMessagesPendingCount();
cur = destination.getMessagesCurrentCount();
sum = pen + cur;
print 'Name: '+destination.getName(),'; Messages Count:',sum,'; Paused: ',destination.isPaused()
if task == 3:
if task == 2:
if task == 3:

To execute:  $WL_HOME/common/bin/



  1. Nikitas


    There is a function on your script:
    -r-x deleteMessages | Integer : String(selector)

    I would like to know how can I use the ‘String(selector)’ parameter.

    I am able to delete all messages of a queue by using deleteMessages function without an argument. But I would like to delete all messages that received on [ SYSDATE – 10 ]. On weblogic GUI there is a column (Time Stamp) that described that, can I use this?

    Great script!

    Thank you,


    1. Dieison santos

      Hi Nikitas.
      Thanks for comment.

      To delete messages with arguments, you can use this sintax:

      cmo.deleteMessages(“JMSTimestamp > 1000”)

      At this example the value need to be in milliseconds, and all messages that have more than 1000 milliseconds will be deleted.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.