Manipulating JMS queues using WLST Script

Hi.

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)

connect('username','passsword','t3://admin_console.net:7001')
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:
destination.pauseConsumption();
if task == 2:
destination.resumeConsumption();
if task == 3:
destination.deleteMessages('');
disconnect()

To execute:  $WL_HOME/common/bin/wlst.sh script_name.py.

Dieison.

One thought on “Manipulating JMS queues using WLST Script

Leave a Reply

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