def exportMessages(serverName,server,jms_module,destination,messageSelector):
try:
serverRuntime()
cd('JMSRuntime/' + serverName + '.jms/JMSServers/' + server + '/Destinations/'
+ jms_module + '!' + server + '@' + destination)
if cmo.getMessagesCurrentCount() > 0 :
print ("No. of current messages are: ")
print cmo.getMessagesCurrentCount()
msgCursor=cmo.getMessages(messageSelector,1000,1)
amountOfMessages=cmo.getCursorSize(msgCursor)
allDestinationMessages=cmo.getNext(msgCursor,amountOfMessages)
print allDestinationMessages
outf = open (server+'-jmsmessages.xml','w')
outf.write('<?xml version="1.0" encoding="UTF-8"?>' + '\n'
+ '<JMSMessageExport>' + '\n')
for jmsmessage in allDestinationMessages:
jmsmsginfo = JMSMessageInfo(jmsmessage)
wlmsg = jmsmsginfo.getMessage()
wlmsgid = wlmsg.getJMSMessageID()
completeMsg = cmo.getMessage(msgCursor,wlmsgid)
outf.write(completeMsg.get("MessageXMLText") + '\n')
outf.write('</JMSMessageExport>')
outf.close()
cmo.closeCursor(msgCursor)
cmo.deleteMessages(messageSelector)
else:
print ("No current message")
except Exception, e:
print('Exception is ')
print e
dumpStack()
raise
|
serverName- Managed Server Name
server- JMS Server Name ( Domain_Name --> Messaging --> JMS Servers )
jms_module- JMS Module name ( Domain_Name --> Messaging --> JMS Modules )
destination- Queue Name
messageSelector- Selecting messages based on jms message properties such as JMS Priority etc.
To modify the script to export pending messages, replace
msgCursor=cmo.getMessages(messageSelector,1000,1)
with
msgCursor=cmo.getMessages(messageSelector,1000,4)
The syntax for getMessages function is:
String getMessages(String selector, Integer timeout, Integer state)
where state is various message states such as 1 for current weblogic jms messages and 4 for pending weblogic jms messages
http://javaheapspace.com/manage-large-amount-of-jms-messages/
ReplyDelete