在WebLogic主机的WebLogic产品目录下的<WLS_HOME>/wlserver_10.3/common/bin目录下执行:
wlst.sh
在交互命令中输入以下红色标明的部分:
注意:以下红色输入部分只是示例,实际输入内容以生产环境中实际的内容为准
[weblogic1036@testserver bin]$ ./wlst.sh
CLASSPATH=/home/weblogic1036/patch_wls1036/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/home/weblogic1036/patch_ocp371/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/usr/java/jdk1.7.0_80/lib/tools.jar:/home/weblogic1036/wlserver_10.3/server/lib/weblogic_sp.jar:/home/weblogic1036/wlserver_10.3/server/lib/weblogic.jar:/home/weblogic1036/modules/features/weblogic.server.modules_10.3.6.0.jar:/home/weblogic1036/wlserver_10.3/server/lib/webservices.jar:/home/weblogic1036/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/home/weblogic1036/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar::.:/home/weblogic1036/utils/config/10.3/config-launch.jar::/home/weblogic1036/wlserver_10.3/common/derby/lib/derbynet.jar:/home/weblogic1036/wlserver_10.3/common/derby/lib/derbyclient.jar:/home/weblogic1036/wlserver_10.3/common/derby/lib/derbytools.jar::
Initializing WebLogic Scripting Tool (WLST) ...
Jython scans all the jar files it can find at first startup. Depending on the system, this process may take a few minutes to complete, and WLST may not return a prompt right away.
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
wls:/offline> connect("weblogic","weblogic123","t3://192.168.75.128:7001")
Connecting to t3://192.168.75.128:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'base_domain'.
Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.
wls:/base_domain/serverConfig> domainRuntime()
Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.
For more help, use help(domainRuntime)
wls:/base_domain/domainRuntime> ls()
dr-- AppRuntimeStateRuntime
dr-- CoherenceServerLifeCycleRuntimes
dr-- ConsoleRuntime
dr-- DeployerRuntime
dr-- DeploymentManager
dr-- DomainServices
dr-- LogRuntime
dr-- MessageDrivenControlEJBRuntime
dr-- MigratableServiceCoordinatorRuntime
dr-- MigrationDataRuntimes
dr-- PolicySubjectManagerRuntime
dr-- SNMPAgentRuntime
dr-- ServerLifeCycleRuntimes
dr-- ServerRuntimes
dr-- ServerServices
dr-- ServiceMigrationDataRuntimes
-r-- ActivationTime Fri Apr 01 13:50:53 CST 2022
-r-- MigrationDataRuntimes null
-r-- Name base_domain
-rw- Parent null
-r-- ServiceMigrationDataRuntimes null
-r-- Type DomainRuntime
-r-x preDeregister Void :
-r-x restartSystemResource Void : WebLogicMBean(weblogic.management.configuration.SystemResourceMBean)
wls:/base_domain/domainRuntime> cd('ServerRuntimes')
wls:/base_domain/domainRuntime/ServerRuntimes> ls()
dr-- AdminServer
wls:/base_domain/domainRuntime/ServerRuntimes> cd('AdminServer')
wls:/base_domain/domainRuntime/ServerRuntimes/AdminServer> ls()
dr-- ApplicationRuntimes
dr-- AsyncReplicationRuntime
dr-- ClusterRuntime
dr-- ConnectorServiceRuntime
dr-- DefaultExecuteQueueRuntime
dr-- EntityCacheCumulativeRuntime
dr-- EntityCacheCurrentStateRuntime
dr-- EntityCacheHistoricalRuntime
dr-- ExecuteQueueRuntimes
dr-- JDBCServiceRuntime
dr-- JMSRuntime
dr-- JTARuntime
dr-- JVMRuntime
dr-- JoltRuntime
dr-- LibraryRuntimes
dr-- LogBroadcasterRuntime
dr-- LogRuntime
dr-- MANAsyncReplicationRuntime
dr-- MANReplicationRuntime
dr-- MailSessionRuntimes
dr-- MaxThreadsConstraintRuntimes
dr-- MessagingBridgeRuntime
dr-- MinThreadsConstraintRuntimes
dr-- PathServiceRuntime
dr-- PersistentStoreRuntimes
dr-- RequestClassRuntimes
dr-- SAFRuntime
dr-- SNMPAgentRuntime
dr-- ServerChannelRuntimes
dr-- ServerSecurityRuntime
dr-- SingleSignOnServicesRuntime
dr-- ThreadPoolRuntime
dr-- TimerRuntime
dr-- WANReplicationRuntime
dr-- WLDFRuntime
dr-- WTCRuntime
dr-- WebServerRuntimes
dr-- WorkManagerRuntimes
dr-- WseeClusterFrontEndRuntime
dr-- WseeWsrmRuntime
-r-- ActivationTime 1648792256942
-r-- AdminServer true
-r-- AdminServerHost 192.168.75.128
-r-- AdminServerListenPort 7001
-r-- AdminServerListenPortSecure false
-r-- AdministrationPort 9002
-r-- AdministrationPortEnabled false
-r-- AdministrationURL t3://192.168.75.128:7001
-r-- AsyncReplicationRuntime null
-r-- ClusterRuntime null
-r-- CurrentDirectory /home/weblogic1036/domains/base_domain/.
-rw- CurrentMachine
-r-- DefaultExecuteQueueRuntime null
-r-- DefaultURL t3://192.168.75.128:7001
-r-- EntityCacheCumulativeRuntime null
-r-- EntityCacheCurrentStateRuntime null
-r-- EntityCacheHistoricalRuntime null
-r-- HealthState Component:ServerRuntime,State:HEALTH_OK,MBean:AdminServer,ReasonCode:[]
-r-- JoltRuntime null
-r-- ListenAddress testserver/192.168.75.128
-r-- ListenPort 7001
-r-- ListenPortEnabled true
-r-- MANAsyncReplicationRuntime null
-r-- MANReplicationRuntime null
-rw- MessagingBridgeRuntime null
-r-- MiddlewareHome /home/weblogic1036
-r-- Name AdminServer
-r-- OpenSocketsCurrentCount 2
-r-- OracleHome /home/weblogic1036
-r-- OverallHealthState Component:ServerRuntime,State:HEALTH_OK,MBean:AdminServer,ReasonCode:[]
-rw- Parent null
-r-- PathServiceRuntime null
-r-- RestartRequired false
-r-- RestartsTotalCount 0
-r-- SSLListenAddress null
-r-- SSLListenPort 7002
-r-- SSLListenPortEnabled false
-r-- ServerClasspath /usr/java/jdk1.7.0_291/jre/lib/resources.jar:/usr/java/jdk1.7.0_291/jre/lib/rt.jar:/usr/java/jdk1.7.0_291/jre/lib/sunrsasign.jar:/usr/java/jdk1.7.0_291/jre/lib/jsse.jar:/usr/java/jdk1.7.0_291/jre/lib/jce.jar:/usr/java/jdk1.7.0_291/jre/lib/charsets.jar:/usr/java/jdk1.7.0_291/jre/lib/jfr.jar:/usr/java/jdk1.7.0_291/jre/classes:/home/weblogic1036/patch_wls1036/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/home/weblogic1036/patch_ocp371/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/usr/java/jdk1.7.0_291/lib/tools.jar:/home/weblogic1036/wlserver_10.3/server/lib/weblogic_sp.jar:/home/weblogic1036/wlserver_10.3/server/lib/weblogic.jar:/home/weblogic1036/modules/features/weblogic.server.modules_10.3.6.0.jar:/home/weblogic1036/wlserver_10.3/server/lib/webservices.jar:/home/weblogic1036/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/home/weblogic1036/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar:/home/weblogic1036/wlserver_10.3/common/derby/lib/derbyclient.jar:/home/weblogic1036/wlserver_10.3/server/lib/xqrl.jar::.
-r-- SocketsOpenedTotalCount 2
-r-- State RUNNING
-r-- StateVal 2
-r-- Type ServerRuntime
-r-- WANReplicationRuntime null
-r-- WLECConnectionServiceRuntime null
-r-- WeblogicHome /home/weblogic1036/wlserver_10.3
-r-- WeblogicVersion WebLogic Server 10.3.6.0.220118 PSU Patch for BUG33494814 Mon Dec 13 10:08:03 UTC 2021
WebLogic Server 10.3.6.0 Tue Nov 15 08:52:36 PST 2011 1441050
-r-- WseeClusterFrontEndRuntime null
-r-x addRequestClassRuntime Boolean : WebLogicMBean(weblogic.management.runtime.RequestClassRuntimeMBean)
-r-x forceShutdown Void :
-r-x forceSuspend Void :
-r-x getIPv4URL String : String(protocol)
-r-x getIPv6URL String : String(protocol)
-r-x getServerChannel java.net.InetSocketAddress : String(protocol)
-r-x getURL String : String(protocol)
-r-x preDeregister Void :
-r-x restartSSLChannels Void :
-r-x resume Void :
-r-x shutdown Void :
-r-x shutdown Void : Integer(timeout),Boolean(ignoreSessions)
-r-x start Void :
-r-x suspend Void :
-r-x suspend Void : Integer(timeout),Boolean(ignoreSessions)
wls:/base_domain/domainRuntime/ServerRuntimes/AdminServer>
wls:/base_domain/domainRuntime/ServerRuntimes/AdminServer> cd('JMSRuntime')
wls:/base_domain/domainRuntime/ServerRuntimes/AdminServer/JMSRuntime> ls()
dr-- AdminServer.jms
wls:/base_domain/domainRuntime/ServerRuntimes/AdminServer/JMSRuntime> cd('AdminServer.jms') cd(‘batch_jms')
wls:/base_domain/domainRuntime/ServerRuntimes/AdminServer/JMSRuntime/AdminServer.jms> ls()
dr-- Connections
dr-- JMSServers
-r-- ConnectionsCurrentCount 9
-r-- ConnectionsHighCount 9
-r-- ConnectionsTotalCount 9
-r-- HealthState Component:null,State:HEALTH_OK,MBean:null,ReasonCode:[]
-r-- JMSServersCurrentCount 1
-r-- JMSServersHighCount 1
-r-- JMSServersTotalCount 1
-r-- Name AdminServer.jms
-r-- Type JMSRuntime
-r-x preDeregister Void :
wls:/base_domain/domainRuntime/ServerRuntimes/AdminServer/JMSRuntime/AdminServer.jms> cd('JMSServers')
wls:/base_domain/domainRuntime/ServerRuntimes/AdminServer/JMSRuntime/AdminServer.jms/JMSServers> ls()
dr-- JMSServer01
wls:/base_domain/domainRuntime/ServerRuntimes/AdminServer/JMSRuntime/AdminServer.jms/JMSServers> cd('JMSServer01')
wls:/base_domain/domainRuntime/ServerRuntimes/AdminServer/JMSRuntime/AdminServer.jms/JMSServers/JMSServer01> ls()
dr-- Destinations
dr-- SessionPoolRuntimes
-r-- BytesCurrentCount 0
-r-- BytesHighCount 0
-r-- BytesPageableCurrentCount 0
-r-- BytesPagedInTotalCount 0
-r-- BytesPagedOutTotalCount 0
-r-- BytesPendingCount 0
-r-- BytesReceivedCount 0
-r-- BytesThresholdTime 0
-r-- ConsumptionPaused false
-r-- ConsumptionPausedState Consumption-Enabled
-r-- DestinationsCurrentCount 0
-r-- DestinationsHighCount 0
-r-- DestinationsTotalCount 0
-r-- HealthState Component:JMSServer.JMSServer01,State:HEALTH_OK,MBean:JMSServer01,ReasonCode:[]
-r-- InsertionPaused false
-r-- InsertionPausedState Insertion-Enabled
-r-- MessagesCurrentCount 0
-r-- MessagesHighCount 0
-r-- MessagesPageableCurrentCount 0
-r-- MessagesPagedInTotalCount 0
-r-- MessagesPagedOutTotalCount 0
-r-- MessagesPendingCount 0
-r-- MessagesReceivedCount 0
-r-- MessagesThresholdTime 0
-r-- Name JMSServer01
-r-- PagingAllocatedIoBufferBytes 0
-r-- PagingAllocatedWindowBufferBytes 0
-r-- PagingPhysicalWriteCount 0
-r-- PendingTransactions null
-r-- ProductionPaused false
-r-- ProductionPausedState Production-Enabled
-r-- SessionPoolsCurrentCount 0
-r-- SessionPoolsHighCount 0
-r-- SessionPoolsTotalCount 0
-r-- Transactions null
-r-- Type JMSServerRuntime
-r-x closeCursor Void : String(cursorHandle)
-r-x forceCommit Void : String(xid)
-r-x forceRollback Void : String(xid)
-r-x getCursorEndPosition Long : String(cursorHandle)
-r-x getCursorSize Long : String(cursorHandle)
-r-x getCursorStartPosition Long : String(cursorHandle)
-r-x getItems javax.management.openmbean.CompositeData[] : String(cursorHandle),Long(start),Integer(count)
-r-x getMessage javax.management.openmbean.CompositeData : String(cursorHandle),Long(messageHandle)
-r-x getMessage javax.management.openmbean.CompositeData : String(cursorHandle),String(messageID)
-r-x getMessages String : String(xid),Integer(timeoutSeconds)
-r-x getNext javax.management.openmbean.CompositeData[] : String(cursorHandle),Integer(count)
-r-x getPrevious javax.management.openmbean.CompositeData[] : String(cursorHandle),Integer(count)
-r-x getTransactionStatus Integer : String(xid)
-r-x pauseConsumption Void :
-r-x pauseInsertion Void :
-r-x pauseProduction Void :
-r-x preDeregister Void :
-r-x resumeConsumption Void :
-r-x resumeInsertion Void :
-r-x resumeProduction Void :
-r-x sort Long : String(cursorHandle),Long(start),String[](fields),Boolean[](ascending)
wls:/base_domain/domainRuntime/ServerRuntimes/AdminServer/JMSRuntime/AdminServer.jms/JMSServers/JMSServer01> cd('Destinations')
wls:/base_domain/domainRuntime/ServerRuntimes/AdminServer/JMSRuntime/AdminServer.jms/JMSServers/JMSServer01/Destinations> ls()
dr-- SystemModule01!Queue01
wls:/base_domain/domainRuntime/ServerRuntimes/AdminServer/JMSRuntime/AdminServer.jms/JMSServers/JMSServer01/Destinations> cd('SystemModule01!Queue01')
在进入到队列之后,执行以下命令:
cmo.deleteMessages("JMSTimestamp < 1648800600000")
如果要删除全部消息,执行以下命令:
cmo.deleteMessages('')