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.

Advertisements

One thought on “Manipulating JMS queues using WLST Script

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s