Friday, December 30, 2011

XPath - Terra Ignota


There are more things in heaven and earth, Horatio,
Than are dreamt of in your philosophy.

As usual before  holidays we've got another issue with timeouts,  adapters errors and database performance.
I found that DB Adapter used several queries and then joins result sets. This way get us right result (very simplified version you can see  bellow) with pretty far from optimal performance. 
<off:OfferActionCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                           xmlns:off="http://xmlns.oracle.com/offer">
  <off:OfferAction>
    <off:id>2121</off:id>
    <off:offerPositionId>
      <off:id>2133</off:id>
      <off:positionNum>3</off:positionNum>
    </off:offerPositionId>
    <off:offerActionDetalCollection>
      <off:OfferActionDetal>
        <off:id>2262</off:id>
      </off:OfferActionDetal>
      <off:OfferActionDetal>
        <off:id>2263</off:id>
      </off:OfferActionDetal>
    </off:offerActionDetalCollection>
  </off:OfferAction>
</off:OfferActionCollection>
Option  'Use Outer Join ..' corrects  query issues , but returns non-unique collection. Like this one:
<off:OfferActionCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                           xmlns:off="http://xmlns.oracle.com/offer">
  <off:OfferAction>
    <off:id>2121</off:id>
    <off:offerPositionId>
      <off:id>2133</off:id>
      <off:positionNum>3</off:positionNum>
    </off:offerPositionId>
    <off:offerActionDetalCollection>
      <off:OfferActionDetal>
        <off:id>2262</off:id>
      </off:OfferActionDetal>
      <off:OfferActionDetal>
        <off:id>2263</off:id>
      </off:OfferActionDetal>
    </off:offerActionDetalCollection>
  </off:OfferAction>
  <off:OfferAction>
    <off:id>2121</off:id>
    <off:offerPositionId>
      <off:id>2133</off:id>
      <off:positionNum>3</off:positionNum>
    </off:offerPositionId>
    <off:offerActionDetalCollection>
      <off:OfferActionDetal>
        <off:id>2262</off:id>
      </off:OfferActionDetal>
      <off:OfferActionDetal>
        <off:id>2263</off:id>
      </off:OfferActionDetal>
    </off:offerActionDetalCollection>
  </off:OfferAction>
</off:OfferActionCollection>

I realised that I don't know much about DB Adapter, so we decide to create XQuery/XPath (or anything else)  to filer collection. 
Well, in fact now I realise that I know about X* almost nothing. By the way, after several hours googling, writing and trying  I found an acceptable message transformation expression.

It loops thru distinct values of OfferAction/id (for clause) and returns first node of Xpath result ( /OfferAction[off:id=$ActionId][1]).
The hardest thing for me was - how to combine XPath filters and expressions.

It works just perfect, but I think that next time I'll play on my own field - 
 queries, indexes and hints.

Happy New Year to everyone! Hope to see you in the next year.


Tuesday, December 27, 2011

Oracle BAM 11g. Report optimizations

I'm trying to keep in touch with our SOA development team. So I've been surprised when I know that they aren't going to maintain and develop any BAM reports for new composites. During discussion they mentioned very poor  reports performance, they tired to optimize it, create several indexes, but without any noticeable result.
Errare humanum est - said Ancient Romans, they leaved to us a lot of such phrases. And  I also have several rules. Meet with one of these:

" The most important part of performance tuning is the database design and optimization"

You can tune heap and garbage collection, you can try to split threads and assign it to separate processor cores. But you always can crate such "great" design, that your efforts will give you almost nothing, because all performance will be limited by disks IO.
I know what you could say, and I have to notice that I'm talking about old-school relational databases. Well lets go back to the BAM case.

After short inspection, I've noticed that there are  only two big data objects, and several lookup tables, so reports were created against classic star - schema.
In fact, I was able to get report with aggregate composites information, but I was not able to open detailed process report.
It's sounds quite strange for me, so I took a look to the  layout of  main data objects.


Lookup fields in the BAM data object
If you are not familiar with BAM, I should explain what BAM data object is.

Using  BAM Architect you can manipulate with data representation objects. Then  you can build reports against your objects in  BAM Studio.  From the other side BAM server publishes  data objects with a set of web services and you can populate it with data. The most common using of BAM is a SOA monitoring  dashboards.

By the way, from the performance tuning perspective you should know two things:
  •  You can build indexes against Data Objects fields. 
  • BAM Data Objects use database tables and indexes to persist information.
Hmmm (I like this sound so much), is there any indexes for lookup fields and in the lookup data objects? The short answer was - NO, and I've immediately created them. 
Actually you can use Data Architect capabilities and don't ask DBA to do this.
Add Index to the data object


Just open Indexes part (1) of data object description and click to Add Index (2). Select object fileds (database columns) and name it.

When I've done it, against all objects and all source and lookup fields. The BAM reports start works, like a charm.   




 

Wednesday, November 23, 2011

Siebel & SOA misscommunication.

Quite confusing situation had resolved couple minutes ago.

The history was started by Sibel implementation team, they have noticed strange hangs for 5-7 seconds while user  process orders. So they started  investigation and founded the reason (They think so). There were detected strange Siebel EAI behavior.
  1. EAI  receive request from a Siebel user
  2. Send it to our LBR-OHS and OSB cluster process it.
  3. Then OSB send response back to EAI
  4. EAI waits for a 5 second 
  5. And then send respond to user.
Siebel team points to wrong  OHS configuration particularly to keepAlive and keepAliveTimeout. It is enabled by default and timeout is 5 seconds. Ping !

The next step was mine. I've create the simplest WSDL for a echoing Proxy Service, and ran several tests with different scenarios, using soapUI.

Well there is no timeouts at all. Actually there were several really long responses, but the min response time was around 5-9 ms, and any average less 100 ms.

I've sent porject, report and explanation to Siebel team. Pong!

Guys  from other side reproduced the test and found the root of the issue.
soapUI uses header user-agent with a value Jakarta Commons-HttpClient/3.0.1, meanwhile Siebel EAI set user-agent to  Mozilla/4.0. Ping !


Hmm, quite strange. When I set user-agent to Mozilla/4.0 I get the same result, the client (soapUI in my case), waits for a keepAliveTimeout and only then responses.
So i don't know how the system behavior will be changed if I switch off keepAlive.

But what I know, that you can change only one parameter in Siebel Enterprise Application Integration and avoid such cumbersome cases.

Monday, November 21, 2011

Oracle Portal and WSRP Producer

If you are developing WSRP portlet provider with JDeveloper/Weblogic, and going to implement some security, you may have some issue like we had.
Or you have not if you wouldn't  use Oracle Portal.
The simplest thing you should  get user name and make some decision or just greet the user. 
So the standard way is:
 .....
PortletRenderRequest portletRequest = (PortletRenderRequest)
                            request.getAttribute("oracle.portal.PortletRenderRequest");
String name = portletRequest.getRemoteUser();
......
Most likely that name will be null. We wasted some time, trying to find the solution. Thanks Google, The Wonderful and Manoj we find it. Here you are:
Add this option to your portlet.xml and you will get user name from Oracle Portal or Webcenter application.
...
<container-runtime-option>
     <name>com.oracle.portlet.useWsrpUserContextForUserAuthenticationInfo</name> 
     <value>true</value>
</container-runtime-option>
.....

P.S. It definitively works with Oracle Portal  11.1.1.4 and WebCenter 11.1.1.5