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.
As i run the script but i am not able to delete the messages.
if task == 3:
Instead of this , which script can be used.
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?
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.
JMSTimestamp is the epoch time.
As we now have ~ 1568980863 cmo.deleteMessages(“JMSTimestamp > 1000”) will remove all messages…
Muito Bom Jython, parabéns Larri