There are several ways monitor messages passing through the Service Bus. Using pipeline alerts is one of them. Pipeline alerts can be searched in the Enterprise Manager based on several parameters such as summary or when they have occurred. Usually an important part of the message payload is saved in the content of the alert. This content can not be searched from the Enterprise Manager. In this post I will provide an example for logging Service Bus request and response messages using pipeline alerts and a means to search alert contents for a specific occurrence. The example provided has been created in SOA Suite 12.1.3 but the script also works in SOA Suite 220.127.116.11.
Service Bus Pipeline Alerts
The Oracle Service Bus provides several monitoring mechanisms. These can be tweaked in the Enterprise Manager.
In this example I’m going to use Pipeline Alerts. Where you can find them in the Enterprise Manager has been described on: https://technology.amis.nl/2014/06/27/soa-suite-12c-where-to-find-service-bus-pipeline-alerts-in-enterprise-manager-fusion-middleware-control/. I’ve created a small sample process called HelloWorld. This process can be called with a name and returns ‘Hello name’ as a response. The process itself has a single AlertDestination and has two pipeline alerts. One for the request and one for the response. These pipeline alerts write the content of the header en body variables to the content field of the alert.
When I call this service with ‘Maarten’ and with ‘John’, I can see the created pipeline alerts in the Enterprise Manager.
Next I want to find the requests done by ‘Maarten’. I’m not interested in ‘John’. I can search for the summary, but this only indicates the location in the pipeline where the alert occurred. I want to search the contents or description as it is called in the Enterprise Manager. Since clicking on every entry is not very time efficient, I want to use a script for that.
Search for pipeline alerts using WLST
At first I thought I could use a method like on: http://docs.oracle.com/cd/E21764_01/web.1111/e13701/store.htm#CNFGD275 in combination with the location of the file-store which is used for the alerts; servers/[servername]/data/store/diagnostics. The dump however of this filestore was not readable enough for me and this method required access to the filesystem of the applicationserver. I decided to walk the WLST path.
The below WLST lists the pipeline alerts where ‘Maarten’ is in the contents / description. I used the following script. The script works on Service Bus 18.104.22.168 and 12.1.3. You should of course replace the obvious variables like username, password, url, servername and searchfor.
import datetime #Conditionally import wlstModule only when script is executed with jython if __name__ == '__main__': from wlstModule import *#@UnusedWildImport print 'starting the script ....' username = 'weblogic' password = 'Welcome01' url='t3://localhost:7101' servername='DefaultServer' searchfor='Maarten' connect(username,password,url) def get_children(): return ls(returnMap='true') domainRuntime() cd('ServerRuntimes') servers=get_children() for server in servers: #print server cd(server) if server == servername: cd('WLDFRuntime/WLDFRuntime/WLDFAccessRuntime/Accessor/DataAccessRuntimes/CUSTOM/com.bea.wli.monitoring.pipeline.alert') end = cmo.getLatestAvailableTimestamp() start = cmo.getEarliestAvailableTimestamp() cursorname = cmo.openCursor(start,end,"") if cmo.hasMoreData(cursorname): records=cmo.fetch(cursorname) for record in records: #print record if searchfor in record: print datetime.datetime.fromtimestamp(record/1000).strftime('%Y-%m-%d %H:%M:%S')+' : '+record+' : '+record cmo.closeCursor(cursorname) cd('..')
The output in my case looks like:
2015-04-18 12:59:21 : Pipeline$HelloWorld$HelloWorldPipeline : HelloWorldPipelineRequest 2015-04-18 12:59:21 : Pipeline$HelloWorld$HelloWorldPipeline : HelloWorldPipelineResponse 2015-04-18 13:18:39 : Pipeline$HelloWorld$HelloWorldPipeline : HelloWorldPipelineRequest 2015-04-18 13:18:39 : Pipeline$HelloWorld$HelloWorldPipeline : HelloWorldPipelineResponse
Now you can extend the script to provide more information or lookup the relevant requests in the Enterprise Manager.