Quantcast
Channel: Alper Karatepe Weblog » alperkaratepe
Viewing all articles
Browse latest Browse all 10

An easy & fast solution for Domain Value Mapping lookup operations

$
0
0

You will find here a very fast solution for DVM lookup operations which needs to be done in Oracle Service Bus proxy services.

I found the following solution during a performance optimization workout for some Oracle Service Bus proxy services in our middleware environment.

Need:

In our middleware environment (Oracle Service Bus), we need to do DVM lookup operations in proxy services.

Old Solution:

  • DVM data was stored in a database and this data was exported to some different xml files with respect to LOV names. (For example, there was city.xml, district.xml …)
  • For each DVM lookup operation in proxy services, a replace action was used.
  • In the replace action, an XQuery was called and target domain value was searched in related xml file by source domain name & value pair. Then, source domain parameter value was replaced with target domain parameter value.

Problem:

  • Although DVM data was stored in a database table (1853 rows), it was exported into some xml files to be used by some other XQuery files inside proxy services.
  • The performance problem was DVM lookup operations were taking approximately 150 ms for each lookup operation. When you need to do 40 DVM lookup operations in a proxy service it takes 6 seconds and it is not an acceptable time for a service execution.
  • Target domain value was searched in some xml files via XQuery and for each operation the doc() function was called and the whole xml file was loaded and then the query was executed over the xml; so, it takes too much time to make a DVM lookup for a domain name & value pair.
  • DVM data should be exported from database into XML files with respect to LOV names. (It is not easy to manage this situation because that you must  provide the data in two different place and they must be synchronous with each other, a small change applied in database must be reflected immediately to xml files)
  • For each DVM lookup operation a replace action was used in proxy service and an XQuery was executed over one of the xml files generated before. This was decreasing the readability of the proxy service (think about 40 replace actions one after another).

New Solution:

Avoid redundant IO operations for each DVM lookup operation

There is an important point that DVM data will not be changed frequently (maybe once a week). So, first of all, we need to avoid searching the DVM lookup result in a file or in a database. It will be waste of time to make IO operations for reading an xml file or make a DB query for each DVM lookup operation.

Store DVM data in memory, and search the result there

I prepared a java class (DvmReader.java) with some static fields which will store DVM data. And this class provides a lookup method to search the target domain value by the given source domain name & value pair and LOV name. Static ArrayLists will composed of LovRecord objects which represents a record of LOV_MAPPING table (DVM data).

Refresh DVM data inside memory periodically

I added a thread which will query database and retrieve DVM data then reload static objects containing DVM data. By doing this, we get rid of the xml files and management of that files. There will be no need to make IO operation, file reading and doc() function for each DVM lookup operation.

Create a custom XPath function to call java method

One more thing to do, how are you going to call this method inside the proxy service? The easiest way is to put a javacallout action instead of each replace action, however, this is not the best solution, the best solution is to create a custom XPath function and call java method by this. By doing this, we also avoided replace actions in the proxy services. You can put all DVM lookup operations inside an XQuery. The proxy services are more readable now. You can easily do this by putting the jar file under the appropriate folder in Oracle Service Bus directory structure (in our environment it was /product/osb1034/osb_10.3.4/Oracle_OSB1/config/xpath-functions) and make the required configuration for the custom XPath function.

To configure the custom xpath function, put the following lines into the file osb-built-in.xml under the same directory you put the jar file:

<xpf:function>
 <xpf:name>lookup</xpf:name>
 <xpf:comment>Returns target domain value for the given source domain name/value pair</xpf:comment>
 <xpf:namespaceURI>http://www.avea.com.tr/om/custom/functions/CustomXpathFunc</xpf:namespaceURI>
 <xpf:className>DvmReader</xpf:className>
 <xpf:method>java.lang.String lookup(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)</xpf:method>
 <xpf:isDeterministic>false</xpf:isDeterministic>
 <xpf:scope>Pipeline</xpf:scope>
 <xpf:scope>SplitJoin</xpf:scope>
</xpf:function>

Call custom XPath function inside an Xquery without a replace or javacallout action need

Then you can call this xpath function inside an XQuery like following:

cusLB:lookup(“ACCOUNT_TYPE”,”OM”,data($searchSIEBELCustomerRequest/ns0:RequestBody/ns0:CustomerType),”SIEBEL”,”")

 At the end,

DVM lookup operation cost is decreased from 150 ms to 2 ms, what more would we want to do.

Please contact me for details and source files (I’m frequently changing the code by now, when a stable version is released, i will put the source files here).

alperkaratepe@gmail.com



Viewing all articles
Browse latest Browse all 10

Trending Articles