Tuesday, February 26, 2013

Delete Messages from JMS Queue in weblogic using WLST


Set classpaths required for WLST from MW_HOME/wlserver_10.3/server/bin/
. ./setWLSEnv.sh
start WLST by typing
java weblogic.WLST

connect('weblogic', 'welcome1', 't3://localhost:7001')
serverRuntime()

cd('/JMSRuntime/<TargetServerName>.jms/JMSServers/<JMSServerName>/Destinations/<JMSModuleName>!<QueueName>')

{ex.- wls:/fmw_domain/serverRuntime>cd('/JMSRuntime/AdminServer.jms/JMSServers/JMSServer1/Destinations/SystemModule1!Queue1')
}

cmo.deleteMessages('')
{This command delete all messaged in queue and will return the number of messages deleted.}

If you want to delete a particular message from the queue, use below command:

cmo.deleteMessages("JMSMessageID IN('ID:<126965.1361894150054.0>')")
Results will be:
1
It will delete a message having id ID:<126965.1361894150054.0>
here is the message ID which we can get from "summary of JMS Message" from Admin Console.

15 comments:

  1. i tried deleting the message for a particular id and it is showing me the output as 0. but when i check from the admin console and also when i did ls() for the particular queue .it is remaining the same . it is not deleting the message . Appreciate if you can help me on this . Thanks


    ReplyDelete
    Replies
    1. If the output is 0, it means it has deleted 0 messages.
      If it deletes the message for that message ID, the output will be 1.
      see if you are using the correct message ID in delete command.

      Delete