Monday, April 20, 2015

Service Monitoring in SOA 11g: Using Oracle BTM 12c

Oracle Business Transaction Management (OBTM) is a Service monitoring tool for Oracle SOA environments. Oracle acquired it from Amber point and has rebranded it along with adding serveral functionalities to make it compatible with the Oracle FMW stack.  Oracle Enterprise Manager (OEM) which provides Server Monitoring capabilities can be used with BTM to provide an end to end Monitoring Capability at Enterprise level.

SOA developers usually rely on either the EM console for monitoring/debugging SOA instances or Oracle Service Bus console (if reporting is enabled) for Service bus flows or log files incase of java components. If the landscape contains all these several components tied together it becomes a nightmare for people supporting/maintaining the system to debug it. 

BTM comes handy in these scenarios:
  • It's a centralized service monitoring tool which gives lot of insights into service transactions.
  • It allows Automatic data collection through BTM Observers, which are non-intrusive in nature (unlike BAM it doesn't require any modifications to existing service code) 
  • It provides an end to end visibility to a service transaction spanning different type of components. (BPEL processes + OSB flows + Java web services+ Database calls etc.)
 At the time of writing this article, I have used SOA Suite/OSB 11.1.1.7 with BTM 12.1.0.6.7 on a 11g R2 DB. I won't cover the various installation/configuration steps for setting up the tool as its well documented in below Oracle link.


I would like to touch upon some of the features the tool provides and a typical topology which will be used in most SOA deployments.

Service Endpoint Monitoring
By default the BTM observers will monitor most of the service end points like BPEL endpoints, OSB Proxy endpoints or Business Services, database adapter calls (create connection, close connection, execute etc), POJOs, JMS queues etc. Even without any transaction creation, you can analyze the data related to each service end point and this data is retained for the configured amount of time (based on logger system policy). You can create custom views of specific service end points related to a particular domain/container which are frequently viewed.

Transactions
Transactions are very useful when you have multiple components in the service interface like OSB, BPEL, Java, DB adapter calls etc. If there are service interactions which are asynchronous in nature, they can also be correlated using Message Fingerprint (a unique key identified by BTM), ECID or some custom message property to link them up. Transactions provide an end to end visibility on the service message flow through the various components and give analysis data like timings and fault details at individual message level if logging is enabled.

SLA Policies/Alerts
SLA policies can be defined on various service end points and email alerts triggered to the concerned stake holders if they are breached. Typical examples would be Avg. response time on a service exceeding a threshold value for a given period of time, Max response time for a service breaching some threshold, number of faults on a critical business service exceeding the high water mark etc.

Based on my experience with the tool:
  • Out of the 5 JVM components in a typical BTM installation, the most important ones are the btmMonitor and btmMain. If the transaction load on servers are high, it would be recommended to horizontally scale the btmMonitor across cluster nodes, as its the one interacting with the Observers installed on all the monitored domains. btmPerformance and btmTransaction are other 2 JVMs...
  • I would say this is a very nice tool for technical people/developers and not something which would be used by Business users. The UI provides very detailed information at a granular level for each service transaction capturing information like throughput, Avg./Max response times, faults etc which can be very useful while doing performance testing of services.
  • The SLA alert emails are very helpful for support team while debugging production issues when end systems aren't responding in a timely fashion.
  • There is a BTM CLI (Command Line Interface) utility provided by the product which can be used to extract service/transaction information based on a time range. This can be used for reporting purposes for use cases like how many transactions ran for more than 30 seconds in a day for a specific service interface.
  • The underlying database tables of BTM is highly de-normalized (perhaps to optimize read performance and render data on the UI faster) but it makes it highly difficult to query specific data. It would be an understatement to say these DB tables are not straightforward to interpret.

Tuesday, May 20, 2014

Large Payload Handling In SOA

There are several use-cases where Integration/Middleware layer is expected to handle large payload (XML/Non-XML) processing. There are many technical challenges with these kind of implementations:

  • How to process such large files (>1 GB) without running into Out Of Memory/Heap Space issues.
  • How to fine tune the design to ensure SLAs are met and data transformations are done efficiently without eating up server resources.
Oracle has published several white papers and articles outlining the various use-cases where Oracle FMW/SOA Suite can be leveraged to process large payloads. These also cover the various best practices/configurations while designing/implementing such integrations.


In this blog post I would cover one such use case of Processing large XML (with repeating structures). Requirement was to concurrently process more than 10 large sized XML files (each > 1GB). Oracle recommends using below approach for this use case:

  • De-batching XML
  • Chunked Read
  • Streaming XPath functions

Steps followed:
  • For me requirement was to ensure input and output file have same sequence of data, so de-batching input XML wasn't an option as that would have generated different output files and merging those at end was a challenge. 
  • Created a BPEL and leveraged File Adapter's ChunkedRead operation. The approach was basically to  invoke read operation on file adapter inside while loop based on the chunk size configured. This will ensure that instead of loading the whole XML file into the memory, chunks of data will be loaded.    JCA : property name="ChunkSize" value="1000";
  • XSLT was be used on smaller payload size rather than the entire large payload. Used properties like streamResultToTempFile which enables XSLT results to be streamed to a temporary file and then loaded from the temporary file instead of caching into memory as a whole document in binary XML format (resulting in OOM errors)
  • Ensured proper JVM heap size settings (4-6 GB), transaction timeout settings (15-20 mins) and audit configurations are done at server level to avoid OOM errors.
With the SOA approach I was able to successfully process only 1 to 2 large files of 1-1.5GB size concurrently. The time taken by BPEL was high (around 5 minutes for single file) and also the heap usage was very high. (XSLT was straight forward direct mapping for few fields only). This BPEL solution didn't scale up for concurrent processing of 3 or more files and started giving "Out Of Memory: Heap space" errors.

Alternative Approach:

With BPEL ruled out, the Plan "B" was to implement core processing logic in Java layer and invoke the java static method from OSB/BPEL using Java callout/Java embedding activities.

Steps followed:
  • File streaming (read/write) was done using java.nio packages as these are faster and more efficient.
  • Method was implemented for file chunking i.e instead of reading and transforming the whole >1GB file, it was split into smaller chunks (4MB size) and processing was carried out each chunk (byte stream).
  • JAXB libraries were used for marshalling and unmarshalling of data and the transformation logic was embedded inside the java code itself.
  • Proper exception handling was implemented to reject bad records in any chunk of data and generate output data with only good data.
Results:
This alternative approach turned out to be a highly scalable solution and also helped in achieving the required SLAs with minimal heap usage.
  • Was able to process 10-12 such large files with less heap usage and in lesser time frame. (** Around 12 minutes for concurrently processing 12 such large files of 1GB size with overall heap usage of 1GB. Below is a JConsole screenshot after processing the files)
  • Load Balancing in Cluster environment was achieved by leveraging OSB Business Service's load balancing capability. This helped in distributing the file processing load across nodes of the cluster.

Tuesday, October 29, 2013

Integrating BAM with BPEL in SOA 11g

Oracle Business Activity Monitoring (BAM) provides ability to create real time dashboards. BAM can act as a centralized monitoring framework across enterprise application integrations. It can pull data from critical points of the business process flow and display those KPIs in real time reports/alerts. With this post I would like to show how simple it is to integrate BAM with BPEL processes (won't get into step wise details for same as there are Tutorials available on OTN and web for the same) . There are 2 ways of integration BAM with BPEL in SOA 11g:

  •  Using BAM adapter 
  •  Using Sensor/Sensor Action inside BPEL.
First and foremost login to your BAM console (http://hostname:port/OracleBAM ) and navigate to the BAM Architect to create the Data Object.











Designing the data object is critical because that determines what exact fields we want to capture from BPEL and send it across to the BAM Active Data Cache.









Next step is to navigate to the BAM Active Studio and create your real time report using the Data Object created above. Active Studio provides various report templates which you can incorporate to build interactive real time dashboards like Pie-Charts, Bar Graphs etc. Based on the requirement these can be designed.

















Once the report is ready and saved, next step is configuring the BAM adapter on the Weblogic Admin console of the SOA server where BPEL code runs (assuming BAM and SOA are running on different servers).

On Admin console, navigate to Deployments-OracleBAMAdapter - Configuration - Outbound Connection 

Pools and expand oracle.bam.adapter.adc.RMIConnectionFactory and click on eis/bam/rmi  (you can use your own JNDI name instead of using the default JNDI).









Once saved, redeploy the BAM adapter for the changes to take effect.

Next step is to move to Jdeveloper and open the BPEL code in the Monitor perspective. Create a BAM sensor variable and assign a sensor action to the same. Inside the orchestration flow you can assign appropriate values to the BAM sensor variable.




































BAM sensor action defines what kind of operation we want to perform. Here we are sending the data to the BAM Data Object created earlier (establish a connection to the BAM server from Jdeveloper to access the DO). The Mapper file maps elements from the BAM sensor variable to the Data Object fields.

Once the code is deployed and BPEL instances are initiated you can navigate back to BAM console and click on Active Viewer - Select your report and watch it get updated in Real-Time with data sent from BPEL. Below is a sample custom report created based on the above Data Object.












These reports have additional capabilities which can be enabled on them like Drill Down feature which lets you click on the Pie Chart/Bar graph and get additional details about that specific data set.

Apart from these custom reports, BAM also ships with an Out-Of-The-Box report feature called Monitor Express which helps in real time composite instance monitoring. Single click enablement from Jdeveloper by switching to Monitor perspective of .bpel file and selecting Monitor Configuration from top left and selecting the specific mode we want to monitor. We can monitor scope level activities or entire BPEL level.

The setup steps which need to be done from back end (BAM server) are :
  • Edit the SOA_HOME/bam/config/BAMICommandConfig.xml and set below 4 properties
  1. ICommand_Default_User_Name
  2. ICommand_Default_Password
  3. ADCServerName
  4. ADCServerPort
  • Next navigate to SOA_HOME/bam/samples/bam/monitorexpress/bin
  • Set JAVA_HOME and run the setup.sh. This script will load the required reports and data objects for the Monitor express dashboard.
You should see something similar to below once this is enabled at runtime.It helps to find how many instances completed/faulted, average processing time of the composites, fault details etc.















BAM is a very powerful and useful feature available from the Oracle SOA stack and can help in setting up Enterprise wide monitoring framework. Hope this post provides a basic understanding of how it can be easily implemented in SOA based integrations.

Sunday, September 15, 2013

Working With Weblogic JMS Bridge

Weblogic messaging bride is a type of forwarding mechanism for JMS messages which can be used to transfer messages between two different domains of weblogic server. Basically the bridge has a Source Destination and a Target Destination which used along with JMS adapter helps to send the messages from one place to other. In this blog post have captured some of the configuration steps for JMS bridge to work:

1. Create a persistent store 
In Admin console; Click Lock and Edit and Under Persistent Stores ; Select New ; Create  FileStore
Name the store and target it to a specific server and finally activate the changes.









2. Create a JMS Server
In Admin console ; Click Lock and Edit and Under JMS Servers ; Select New
Set a name and select the corresponding FileStore and set the target to a specific server and after finishing, finally activate the changes

3. Create JMS Module
In Admin console ; Click Lock and Edit and Under JMS Servers  ; Select New
Click Next and Target it to the Servers and again click next. In the below page select the Check Box and click finish.







Click on the JMSModule and navigate to the Subdeployments page and click on New. Select a name and also target it to the JMS servers created earlier.

4. Create Connection Factory













Provide Name and JNDI name leaving rest fields as default and in next page click on Advanced targeting and select the subdeployment created earlier












5. Create Queue
Next create a Distributed JMS queue providing name and JNDI and under Advanced targeting, select the subdeployment created. Once finished activate the changes.











6. Create JMS Bridge Destinations
First create the source bridge destination.
In Admin console ; Click Lock and Edit and Under JMS Bridge Destinations ; Select New 
Provide the below details:
Connection URL: t3://source hostname:port/
Connection Factory JNDI Name: 
Destination JNDI Name: 

Click on OK and then click on source bridge destination name and ensure that the Weblogic credentials are correctly set there. This would be source server/domain credentials from where messages will be read.

Similar fashion create a target bridge destination and provide corresponding details.

NOTE: If weblogic is installed on a clustered server, the Connection URL format will be:
t3://node1 hostname:port,node2 hostname:port

Once done activate changes.

7. Create JMS Bridge
In Admin console ;Click Lock & Edit and Under Bridges ; Select New.
Provide name, select the corresponding source and target JMS destinations and finally click on Finish.

If all configuration is correct, we should see the below status for the JMS bridge under Monitoring tab.









NOTE :
For the XA Adapter to work the following file has to be deployed to Weblogic with name
jms-xa-adp  from /MW_Home/wlserver_10. 3/server/lib/jms-xa-adp.rar
Else the JMS bridge may give an error  "WARN: Failed to find the source/target adapter "

Apart from the JMS bridge configuration, need to create the corresponding JNDI name under deployments which will be used at runtime and this should be have the correct Connection factory(created in step4) configured in it.

The same JNDI name configured above will be used at design time while configuring the JMS adapter in Jdeveloper. Also the target destination name (JMS queue created in step5) will be configured in JMS adapter.

Tuesday, April 9, 2013

SOA 11g: Managed server error "weblogic.messaging.kernel.KernelException"

Recently came across an issue where the Managed servers were failing with below error. Even though servers start and come to running mode, but the JMS queues are not showing up in admin console under JMS Servers->Monitoring -> Active Destinations


<Error> <JMS> <BEA-040123> <Failed to start JMS Server "JMS_DEV_SERVER1" due to weblogic.jms.common.JMSException: weblogic.messaging.kernel.KernelException: Ignoring 2PC record for sequence=4706 queue=57 because the element cannot be found.
weblogic.jms.common.JMSException: weblogic.messaging.kernel.KernelException: Ignoring 2PC record for sequence=4706 queue=57 because the element cannot be found
        at weblogic.jms.backend.BackEnd.open(BackEnd.java:1008)
        at weblogic.jms.deployer.BEAdminHandler.activate(BEAdminHandler.java:200)
        at weblogic.management.utils.GenericManagedService.activateDeployment(GenericManagedService.java:239)
        at weblogic.management.utils.GenericServiceManager.activateDeployment(GenericServiceManager.java:131)
        at weblogic.management.internal.DeploymentHandlerHome.invokeHandlers(DeploymentHandlerHome.java:632)
        Truncated. see log file for complete stacktrace

This issue was after effect of the JMS file persistence store hitting 100% space utilization. As a result of which it got corrupted and was causing the JMS servers to fail while starting/activating.

To workaround this error, go to the Persistence File Store location (local/Shared SAN storage) and rename the existing *.DAT files to _bkp (say). Then go ahead and restart the managed servers. Now servers should come up fine without any issues/errors.

Oracle Metalink Note 1473826.1 "FileStore getting corrupted and WLS is unable to initialize JMS leading to BEA-040123 " suggests applying a Weblogic patch for Bug13900234. I haven't tried applying this patch but if issue persists inspite of workaround you can try this option as well.

Saturday, April 6, 2013

Automating SOA 11g Admin tasks using WLST

WLST (Weblogic Scripting Tool) is a powerful feature for Weblogic administrators who want to automate most of their day to day operational tasks. This was initiated back in the BEA Weblogic 8.1 days for standalone weblogic server administration. And since Oracle SOA Suite 11g is now based on Weblogic server, this tool has become handy for SOA suite administrators.

There are lot of good learning materials available online for people getting started with WLST apart from the standard Oracle documentation. Few noteworthy ones are mentioned below. These links provide some nice examples with sample code which you can use based on your needs.

With this post I just wanted to give an overview on the different use cases where WLST can be used and how it eases lot of the operational tasks for SOA suite admins.

Common Use Cases 
  • Monitoring STUCK threads/Hogging threads 
  • JMS thread pool monitoring
  • Retiring/Activating SCA composites
  • Enabling/Disabling OSB proxy/business services
  • Deploying SCA/OSB code
  • Deploying/Updating other resources like JMS queues, JDBC datasources etc.
  • Pausing/Resuming consumption/production on JMS queues
  • Moving messages between JMS servers
  • Generating Thread dumps and sending email alerts.
The main thing about working with WLST is understanding of how to navigate the configuration/runtime management beans(MBeans) and how to change the MBean attribute values.


You can either directly connect to the WLST command prompt and execute the necessary commands after connecting to the runtime environment. An example shown below for retiring a SCA

  cd mw_home/Oracle_SOA1/common/bin
  ./wlst.sh

  Initializing WebLogic Scripting Tool (WLST) ...
 
  Welcome to WebLogic Server Administration Scripting Shell
 
  Type help() for help on available commands
 
  wls:/offline> connect ("username","password","t3://admin_hostname:port")
  
  Connecting to t3://admin_hostname:port with userid username ...
  Successfully connected to Admin Server 'AdminServer' that 
  belongs to domain 'SOA_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:/SOA_DOMAIN/serverConfig> sca_retireComposite("listen address",
  "username","password","sca name","sca version",partition="partition_name")

The other way to execute is by writing WLST scripts (.py extension) which are similar in structure to Python language and include a lot of Python as well as Jython (Java implementation of python) libraries. Next you write some shell script (.sh) which invokes these .py files and can schedule the same on the crontab at specific intervals.

The shell script (.sh) basically sets the environment (CLASSPATH and PATH) by calling setWLSEnv.sh and then running the WLST script by calling it as below.

   java weblogic.WLST xxxx.py

Tuesday, November 6, 2012

Looping In XSL

XSL is a functional language and not a programming language !! XSL variables are not actually variables, once set you cannot change their value !! Why is a for loop not working inside XSL !!

I hope many of us have encountered these questions while using XSL. I have come across many scenarios where I had to create a XSL to iterate through a XML and generate some output but looping is tricky inside XSL. Sure you can run a while loop inside BPEL and get your values assigned but that's clumsy.

Below is some sample code snippet which can be extended based on your requirements and should come handy when trying to loop inside XSL.

  <xsl:template match="/">
  <root>
     <xsl:call-template name="loop">
         <xsl:with-param name="i" select="1" /> 
         <xsl:with-param name="count" select="//code to find the counter for loop" /> 
     </xsl:call-template>
  </root>
  </xsl:template>

  <xsl:template name="loop">
     <xsl:param name="i" /> 
     <xsl:param name="count" /> 
     <xsl:if test="$i <= $count">
        //your code here.You can use the predicate [position() = $i] for correct assignments.
           <xsl:call-template name="loop">
           <xsl:with-param name="i" select="$i + 1" /> 
           <xsl:with-param name="count" select="$count" /> 
           </xsl:call-template>
     </xsl:if>
  </xsl:template>
Hope this helps..