Thursday, June 06, 2013

OSB-Parallel Programming with Static and Dynamic Split-Join

JAVA

In Java language, we can make one Thread to wait for another by using join method. 
private void startThreads(int nfOfThreads) {
  Thread[] threads = new Thread[nfOfThreads];
  //start the threads
  for (int i = 0; i < threads.length; i++) {
    threads[i] = new ThreadTestWithoutJoin.MyThread();
    threads[i].start();
  }
  //join the threads
  for (int i = 0; i < threads.length; i++) {
    try {
      threads[i].join();
    } catch (InterruptedException e) {}
  }
}

NOTE:
In the above code, there are two for-loops, the first to create and start each thread, and the second loop to join each thread. If each thread is joined right after start, the effect is these threads are executed sequentially, without the desired concurrency.
// The following is NOT concurrent:
private void threadTest(int numOfThreads) {
 Thread[] threads = new Thread[numOfThreads];
 for (int i = 0; i < threads.length; i++) {
     threads[i] = new foo.ThreadTest.MyThread();
     threads[i].start();
     try {
         threads[i].join();
     } catch (InterruptedException ignore) {
     }
 }
}
(Refer http://javahowto.blogspot.ca/2007/05/when-to-join-threads.html)

WLI

In WLI, A Parallel node represents a point in a business process at which a number of activities are executed in parallel. By default, parallel nodes contain an AND join condition. In this case, the activities on all branches must complete before the flow of execution proceeds to the node following the parallel node. You can change the join condition to OR. 

NOTE:
Parallel branches of execution in a business process are logically parallel; physically the branches are executed serially by the business process engine. While one branch of execution is waiting for a response, another branch of execution in the parallel flow can progress.
(Refer http://docs.oracle.com/cd/E13214_01/wli/docs102/bpguide/bpguideParallelDesign.html, http://docs.oracle.com/cd/E13214_01/wli/docs102/jpdtutorial/tutWLIProcessParallel.html)

OSB

In OSB, Split-Join feature lets you split a service payload, such as an order, into individual messages for concurrent processing. Concurrent processing, as opposed to sequential processing, greatly improves service performance. Split-Join achieves this task by splitting an input message payload into sub messages (split), routing them concurrently to their destinations, and aggregating the responses into one overall return message (join). This process of payload splitting and response aggregation is called a Split-Join pattern.we can create Split-Join flow for parallel programming. There are two types of Split-Join, one is static and another one is dynamic.

The Static Split-Join can be used to create a fixed number of message requests
The Dynamic Split-Join can be used to create a variable number of message requests.

Any webservice needs a WSDL, Split-Join flow is the same and the first thing we need to do is to create a WSDL. Every Split-Join is based upon a WSDL operation. When you first create a Split-Join, you will be asked to browse to the appropriate WSDL file and to select an operation as part of the creation process. The WSDL of Split-Join flow can be same as the proxy service which will invoke the flow or you can defined a totally different WSDL. The choice is really based on your requirement.

For dynamic Split-Join, please refer the follow blogs. As these blog is pretty detail, I won't write anything.
http://biemond.blogspot.ca/2008/11/split-join-in-oracle-service-bus.html
http://www.xenta.nl/blog/2011/07/03/oracle-service-bus-implementing-aggregator-pattern-by-use-of-split-join/
http://rohanlopes.blogspot.in/2011/10/implement-parallel-split-join-osb.html

For static Split-Join, I got few help from the internet. But it is pretty easy when you have done a dynamic one.
First, create a new Split Join based on the WSDL operation you want to use.  In the Split-Join editor, you can see following flow, which consists of a Start Node, a Receive, a Reply. By clicking the triangle icon beside of Start Node, you can see the Start Node contains both a Request Variable and a Response Variable that have been determined by the WSDL operation initially selected. You can change the variables' name same as what you did in dynamic Split-Join. The Receive Node receives the incoming request message, and the Reply Node generates a response message and sends it back to the client.
Debugging a proxy service
Second, add an Assign Node after the Receive Node to initialize the Response Variable in a form such that the later nodes can work on the data within it. This output message is relayed to the final Reply node in the Split-Join and, in turn, returned to the original client.
Third, add a Parallel Node. The Parallel Node contains two main branches at the beginning, you can add more by clicking on the plus icon. Each branch is composed of a number of actions, the sequence and general configuration being the same for both branches.
Debugging a proxy service

Forth, add an Invoke Service Node. On the properties tab, config the service and operation. Select the Input Variable to create a new request variable and then select the Output Variable to create response variable. The result will be stored in the output Variable. The service you reconfigured for each branch may be not the same based on your requirement.

Fifth, add an Assign/Copy/Insert/Replace before the Invoke Service Node to prepare the input variable for service invocation. As the service invoked may be different, the logic in the node is not the same.

Sixth, add an Assign/Copy/Insert/Replace after the Invoke Service node to put the data in the Output Variable to the response variable of flow.

When you done everything you need, you can follow the steps in dynamic Split-Join to generate a business service. Then you can invoke it and test it in a proxy service.

If you have the book The Definitive Guide to SOA, you can look at the chapter 7 Parallel Calls with Split-Join for help as there is more detail.
(Reference http://docs.oracle.com/cd/E13159_01/osb/docs10gr3/eclipsehelp/tasks.html#wp1150654)

When I opened the source code of flow in text editor, I found the flow is implemented with BPEL instead of genera OSB xml.

Tuesday, May 14, 2013

OSB-SOAP Action Header Issue

Issue:
Recently, I worked on an existing code developed by somebody else long time ago and a defect was opened for SOAP action header issue. The invoked web service always complained 'no SOAPAction header!'.

As the business service was developed by vendor and they used RPC style, we have to define the business service as any XML service. (If we defined as a WSDL webservice, OSB threw exception when it got the response - unrecognized response.) As the business service was set an any XML service, it looks like the the OSB can automatically set soap action header.

Resolution:
In OSB proxy service, before the service callout, put a replace action to replace the soap action hdead in outbound.
In this application, I just used the soap action header of inbound to replace the one of outbound by the easiest way. (From the OSB console, I saw the soap action header is empty string for the initial request and same as the one needed for the service call, then I just copied them from Inbound Request.)

Note: A Transport Headers action looks like not work properly and the soap xml was modified by OSB automatically and caused an additional soap body was added to the soap envelop incorrectly.

SOAPAction References:

Wednesday, May 08, 2013

Java synchronized methods: lock on object or class

http://stackoverflow.com/questions/437620/java-synchronized-methods-lock-on-object-or-class

In section 8.1.1 of the Java Language
Specification, third edition. The valid modifiers for a class are any
annotation, public, protected, private, abstract, static, final, or
strictfp. It is illegal to place the keyword "synchronized" in front of
a class.

The Java Tutorials say: "it is not possible for two invocations of synchronized methods on the same object to interleave." What does this mean for a static method? Since a static method has no associated object, will the synchronized keyword lock on the class, instead of the object?
Yes.

Synchronized method acquires a monitor (§17.1) before it executes. For a class (static) method, the monitor associated with the Class object for the method's class is used. For an instance method, the monitor associated with this (the object for which the method was invoked) is used.

One point you have to be careful about (several programmers generally fall in that trap) is that there is no link between synchronized static methods and sync'ed non static methods, ie:
class A {
static synchronized f() {...}
synchronized g() {...}
}

Main:

A a = new A();
Thread 1:

A.f();
Thread 2:

a.g();
f() and g() are not synchronized with each other and thus can execute totally concurrently.

Unless you implement g() as follows:
g() {
synchronized(getClass()) {
...
}
}
I find this pattern useful also when I want to implement mutual exclusion between different instances of the object (which is needed when accesing an external resource, for example).

SOA - Set Loopback for SOA suite installation on a DHCP host

In order to install SOA suite on a DHCP host, we need to set the loopback. If you have installed VM ware or Virtual Box, you are lucky and the loopback had been created. If not, just follow the follow steps to create a loopback.

(From http://docs.oracle.com/cd/E16764_01/install.1111/e14318/qisoa.htm#BGBJEFDH)

3.7 Installing on DHCP Hosts

If you are installing Oracle SOA Suite on a DHCP host, you must follow the configuration steps in this section for your platform.

3.7.1 For UNIX Platforms

On UNIX operating systems, configure the host to resolve host names to the loopback IP address by modifying the /etc/hosts file to contain the following entries:
127.0.0.1 hostname.domainname hostname
127.0.0.1 localhost.localdomain localhost
After doing so, check that the hostname resolves to the loopback IP address by entering the following command:
/bin/ping hostname.domainname

3.7.2 For Windows x86 Platforms

On Windows systems, install a loopback adapter on the DHCP server (see Section 3.7.3, "Installing a Loopback Adapter (Windows Only)"). This assigns a local IP address to your computer.
After installing the adapter, add a line to the %SYSTEMROOT%\system32\drivers\etc\hosts file with the following format, immediately after the localhost line:
IP_address   hostname.domainname   hostname
Replace IP_address with the local IP address of the loopback adapter.

3.7.3 Installing a Loopback Adapter (Windows Only)

To install a loopback adapter on Windows 2003 or Windows XP:
  1. Open the Windows Control Panel.
    Windows 2003: Select Start > Control Panel > Add Hardware.
    Windows XP: Select Start > Control Panel, then double-click Add Hardware.
  2. In the "Welcome" window, click Next.
  3. In the "Is the hardware connected?" window, select Yes, I have already connected the hardware, then click Next.
  4. In the "The following hardware is already installed on your computer" window, in the list of installed hardware, select Add a new hardware device, then click Next.
  5. In the "The wizard can help you install other hardware" window, select Install the hardware that I manually select from a list, then click Next.
  6. In the "From the list of hardware types, select the type of hardware you are installing" window, select Network adapters, then click Next.
  7. In the "Select Network Adapter" window, make the following selections:
    • Manufacturer: Microsoft
    • Network Adapter: Microsoft Loopback Adapter
  8. Click Next.
  9. In the "The wizard is ready to install your hardware" window, click Next.
  10. In the "Completing the Add Hardware Wizard" window, click Finish.
  11. If you are using Windows 2003, restart your computer.
  12. Right-click My Network Places on the desktop and choose Properties. This displays the Network Connections Control Panel.
  13. Right-click the connection that was just created. This is usually named "Local Area Connection 2". Choose Properties.
  14. On the "General" tab, select Internet Protocol (TCP/IP), then click Properties.
  15. In the "Properties" dialog box, click Use the following IP address and do the following:
    1. IP Address: Enter a non-routable IP for the loopback adapter. Oracle recommends the following non-routable addresses:
      192.168.x.x (x is any value between 1 and 255)
      10.10.10.10
      
    2. Subnet mask: Enter 255.255.255.0.
    3. Record the values you entered, which you will need later in this procedure.
    4. Leave all other fields empty.
    5. Click OK.
  16. In the "Local Area Connection 2 Properties" dialog, click OK.
  17. Close Network Connections.
  18. Restart the computer.

3.7.4 Removing a Loopback Adapter (Windows Only)

To remove a loopback adapter on Windows 2003 or Windows XP:
  1. Start the System Control panel.
    Windows 2003: Select Start > Control Panel > System.
    Windows XP: Select Start > Control Panel, then double-click System.
  2. In the "Hardware" tab, click Device Manager.
  3. In the "Device Manager" window, expand Network adapters. You should see Microsoft Loopback Adapter.
  4. Right-click Microsoft Loopback Adapter and select Uninstall.
  5. Click OK.

Oracle SOA Suite Basic

In SOA suite, we must understand the follow concepts.

  • Adapter - used to connect resources
  • Mediator - Route and Transform
  • Rule Engine - Business Rules
  • BPEL Process - Orchestration
  • Human Workflow - Involve human beings
  • Security Framework - Policy-based security
  • BAM - Business Activity Monitor, visualization of process running


What is SCA?

SCA - Service Component Architecture, which is a specification backed by a growing number of leading industry vendors (http://www.OSOA.org) and being standardized at OASIS, the international open standards consortium . SCA is:
  • language-neutral
  • component model 
  • assembly model
SCA terminologies:
  • Composite: deployment unit
  • Service: entry-point into composite
  • Component: provides logic
  • Reference: refers to external services
  • Wire: connects services, components and references – no special semantic.
SOA Composite:
  • SOA composite is a standards-based deployment unit
  • Leverages the SCA assembly model
  • Can mix variety of components: Mediator, BPEL, Human Workflow, etc.


Thursday, April 25, 2013

Token Configurations in Oracle SOA Suite PS6


Eventually, we find a way to deploy our application easier and can modify the endpoint of service instead of redeploy the application with deployment plan.

References:
http://docs.oracle.com/cd/E28280_01/dev.1111/e10224/sca_bindingcomps.htm#CIHFJFJC
http://biemond.blogspot.ca/search?updated-min=2013-01-01T00:00:00%2B01:00&updated-max=2014-01-01T00:00:00%2B01:00&max-results=3

Handle a transaction between OSB and SOA suite

Recently looked at how to handle a transaction between OSB and SOA suite. From all of document I found, the HTTP protocol can not support transaction however you set your service. If we want them to support transaction, we have to use direct binding.
In composite, we need to modify the reference to set <binding.direct> .
For SOA-OSB, we should set the transport protocol to sb protocol of proxy service.
For OSB-SOA, we should set the transport protocol to soa-direct of business service.

For the features of SOA-Direct, see OSB-SOA Direct transport

For how to implement a global transaction, we can refer to Edwin blog.
Global Transactions and Quality of Service in OSB

References
http://docs.oracle.com/cd/E14571_01/integration.1111/e10224/invocapi.htm#SOASE85537
http://docs.oracle.com/cd/E14571_01/doc.1111/e15866/soa.htm
http://biemond.blogspot.ca/2010/11/global-transactions-and-quality-of.html





Monday, December 03, 2012

OSB-Thread model in OSB


When you handle a performance issue in your development, you much want to know how the system handle the request and how to utilize the thread management. For OSB, I heard many stories and complains about servers being hang. 

Recently, I began to work on OSB and wondered how OSB handle the request and response and how the thread is used. Then I searched with Google and found the follow useful blogs about the thread model in OSB. I found the usage of thread is kind of tricky with different implementation in OSB code. Some of implementation may cause performance issue and thread lock. With the follow blogs, you can get much familiar with the OSB thread model and know how to make it work much stable.

Following the Thread in OSB
https://blogs.oracle.com/reynolds/entry/following_the_thread_in_osb

Oracle Service Bus: thread blocking evidences, transport level
http://mazanatti.info/index.php?/archives/73-Oracle-Service-Bus-thread-blocking-evidences,-transport-level.html

OSB performance issue
http://sgrosjean.blogspot.ca/2013/02/osb-performance-issue-v.html


Friday, October 19, 2012

SOA - Using Preferences in Oracle SOA Suite 11g


In the Oracle SOA 11g, we can add a preferences in composite.xml and use it in our BPEL process.
Where to add?
In the composite.xml, locate the component element.
  <component name="SubmitHUPOrderWireless" version="2.0">
    <implementation.bpel src="SubmitHUPOrderWireless.bpel"/>
    <property name="bpel.preference.timeout">PT240S</property>
  </component>

In the BEPL, we can use it by the follow code.
  <onAlarm>
       <for>ora:getPreference('timeout')</for>
       <assign name="AssignTimeoutFault">
             <copy bpelx:insertMissingToData="yes">
                  <from>'System Timeout'</from>
                  <to>$fault_var/Body/Exception/ExceptionType</to>
             </copy>
        </assign>
  </onAlarm>

OSB-SOA Direct transport

The OSB provides a SOA-DIRECT transport that can be used to invoke Oracle SOA Suite service
components, such as BPEL processes, human tasks, rules, and Oracle Mediator components. The SOA-DIRECT transport provides native connectivity between OSB services and Oracle SOA
Suite service components.

The features supported by SOA-DIRECT transport:
  • Invocation of any SOA binding component services through Java Remote Method Invocation (RMI)
  • WS-Addressing
  • Identity propagation
  • Transaction propagation
  • Attachments
  • Optimized RMI transport for invoking SOA services
  • High availability and clustering support
  • Failover and load balancing (not available for services in the service callback role)
  • Connection and application retries on errors
The SOA-DIRECT transport uses WS-Addressing for message correlation in synchronous and asynchronous communications.

For Security, the SOA-DIRECT transport supports one-way SSL. To use SSL, enable SSL in the domain, use the secure protocol in the endpoint URI, such as https, iiops, or t3s, and reference the secure port in the URI.


The SOA-DIRECT transport stores the following environment values for SOA-DIRECT services:

  • JNDI Service Account (security category)
  • Pass Caller's Subject (security category)
  • Invocation Service account (security category)
  • Work Manager (environment category)

Synchronously invoking a SCA composite from an OSB service
The SOA-DIRECT transport supports transactions and identity propagation across JVMs and
uses the T3 RMI protocol to communicate with the SOA Suite server.

Note:
The SOA Suite and the OSB server must be on the same patch set level, otherwise we can get java class version errors.

The SOA-Direct transport supports WSDL type services with SOAP 1.1, SOAP 1.2, or, alternatively, XML bindings. The SOA direct binding framework only exposes direct binding services as WSDL with SOAP 1.1 and SOAP 1.2 bindings, not XML. However, if you want to use an XML binding, you must manually customize the imported SOA service WSDLs for the direct binding services. An XML binding has no effect on the message payload, since messages between the SOA-DIRECT transport and SOA binding components are always abstract (no binding).

References:

SOA - Why we need a wrapper wsdl?

In Oracle SOA, when we create a webservice reference in composite and link it with BPEL component, a wrapper wsdl may be generated. What is the purpose of wrapper wsdl?

The wrapper wsdl will be added specific elements for BPEL in SOA suite - partner link information.


    <plnk:partnerLinkType name="FinalCheckIntegrity">
        <plnk:role name="IPricePlanService" portType="tns:IPricePlanService"/>
    </plnk:partnerLinkType>



Thursday, September 06, 2012

Web Service Data Binding Style



Wrapper Style - the root element of the message (wrapper element) is the operation name, which is not part of the payload.  The children of the root element must map directly to parameters of the operation's signature.

Non-Wrapper Style (bare) - the entire message is passed to the service operation. The reply message is handled in a similar way.

Wrapper or Non-Wrapper can only be used in conjunction with the document/literal style defined in WSDL.  It defines how web service request or reply messages are interpreted.


public String helloworld(
        @WebParam(name = "firstName")String firstName, 
        @WebParam(name = "lastName") String lastName );
The request looks like:
<soap:Envelope 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Body>
    <helloworld xmlns="http://personservice">
      <firstName>John</firstName>
      <lastName>Doe</lastName>
    </helloworld>
  </soap:Body>
</soap:Envelope>

public String helloworld(
        @WebParam(name = "name", targetNamespace="http://www.myname.com") 
        Name name );
The request looks like:
<soap:Envelope 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soap:Body>
    <ns0:name xmlns:ns0="http://www.myname.com">
      <firstName>John</firstName>
      <lastName>Doe</lastName>
    </ns0:name>
  </soap:Body>
</soap:Envelope>


In JAX-WS, "SOAPBinding" annotation can be used to specify the style.
@SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)

Note
The parameter style "WRAPPED" is the default. In JAX-RPC the "WRAPPED" style is specified in the web service mapping xml file by adding "wrapped-element" element to the service endpoint mapping.

The wsdl2java will automatically assume " WRAPPED" if operation name matches the wrapper element name.

Wrapper or Non-Wrapper are a data binding style and not part of the contract of a web service, also it is not mentioned in the WSDL file.The web service client can be implemented with "non-wrapper" style for and should interoperate with a "wrapper" service without a hitch in theory at least.

The wrapper style is supported widely event it is not universally. The wrapper style is really an RPC-style binding over "document/literal" WSDL style. The method name is explicitly provided in the message.

Advantages of wrapper style.



  • Wrapper service can only have one message part in WSDL, which guarantees that the message (consisting of the method element that contains parameters) will be represented by one XML document with a single schema.
  • RPC style message definitions in WSDL have to use schema types, whereas with the document style we can refer directly to element names. This makes XML message representation more "precise", it is also easier to validate.

The wrapper style has one interesting drawback as it may not be immediately obvious. If a service signature changed, for example, a new parameter was added, clients will have to change as well. With wrapper style, all parameters have to be present in the XML message although they can be defined as null using "xsd:nil" attribute. This is despite the fact that the element corresponding to the parameter can be defined as optional in the schema. The non-wrapper style does not have this problem and adding a new optional element does not affect clients as binding is always name-based. This creates somewhat tighter coupling between wrapper style consumers and providers.

JAX-WS does impose some additional restrictions on the wrapper style. The most important one is the wrapper element's content type must be "sequence". By this, a method's signature always represented as an ordered list of arguments.

For non-wrapper style, the most obscure thing is how a SOAP engine decides which operation to invoke based on the message type when a web service has multiple operations as operation name is not explicitly provided by the message. The "SOAPAction" header can be used for that purpose, however this header is HTTP-only and also optional in JAX-WS. For "non-wrapper", each operation must accept a message that corresponds to a unique XML element name. Note that it is not enough to define different WSDL messages using "wsdl:message" element, each message must be represented by a different element in the schema. Web service engines use unique element names to determine Java method names that correspond to WSDL operations. This also means that with non-wrapper you CANNOT have different operation names processing the same message.

The wrapper does not support overloaded methods.
The non-wrapper does not support methods with the same signature.

Thursday, August 16, 2012

OSB 11g ANT Build Scripts

Please reference to the follow blog.
http://biemond.blogspot.ca/2010/07/osb-11g-ant-deployment-scripts.html

Notes:
Use setDomainEnv.cmd to set the env properly.

http://www.javamonamour.org/2011/07/oracle-service-bus-configuration-jar.html

https://cn.forums.oracle.com/forums/thread.jspa?threadID=943099

Problem
In general this OSB export works fine, this error occures only if any OSB project contains proxy/business services using JCA transport e.g. used by the DB or SAP adapter.
Solution Summary
Add system property "com.bea.plateng.common.util.logging.useJDKlogger" set to "true" for configexport task, so that ANT target body look like:


<java \[...] jar="\[...]/org.eclipse.equinox.launcher_1.0.1.R33x_v20080118.jar">
\[...]
<sysproperty key="com.bea.plateng.common.util.logging.useJDKlogger" value="true"/>
</java>


Solution Description
The problem is in OSB module "com.bea.cie.comdev", which provides custom logging abstraction classes. Class com.bea.plateng.common.util.logging.LogFactory dynamically detects log4j library. If it is found, returns Log4jLogger, otherwise Jdk14Logger. The problem is that it uses context class loader for log4j detection and current class loader for Log4jLogger instantiation. In runtime, detection finds log4j installed in plugins/ directory (version 1.2.13), but instantiation finds none.

Specified parameter disables log4j detection.

Tuesday, June 26, 2012

OSB - Assign and Conditional Branch



The Conditional Branch is not possible directly to handle multiple compares. Using Assign to work around such scenario is doable.

1. Add a pipeline pair before the conditional branch
2. Add a stage in the request pipeline
3. Add an assign action in the stage to create a variable name as x, which will be using in the conditional branch


The XQuery expression in Assign Action:

for $type in $body/request/type
return
if ((data($type) = 'a') or (data($type) = 'b') or (data($type) = 'c')) then 
    <BranchValue>branch1 < /BranchValue>
else if ((data($type) = 'x') or (data($type) = 'y') or (data($type) = 'z')) then
    <BranchValue>branch2 < /BranchValue>
else ()

Then the conditional branch can work with the variable defined in above step to compare against 'branch1' or 'branch2' as values. The XPath should be $x/BranchValue/text().

Tuesday, June 12, 2012

OSB - fn-bea:execute-sql vs JCA DBAdapter



1. Issue with a structure changes of DB
The JCA DB Adapter is tightly coupled to the DB structure. A rework is always needed to reflect any DB table structure changes (such as adding new fields or removing some fields, modifying data types). We have to regenerate the WSDL using JDeveloper & and make impacting changes in OSB services.

The fn-bea:execute-sql() function is much flexable and just change the select query used in the function, no additional changes.

2. Reusability
The JCA DB Adapter is a reusable across projects/products. All Oracle SOA products (BPEL, ESB, OWSM, Oracle BPM) use the same adapter. In case you want to migrate to a different product from OSB then there is less migration effort for the JCA DBAdapter.

3. Performance
For simple select queries, both of them seem to give a similar performance. But the bea function was more expensive than the DBadapter as the number of records in the DB tables increase.

Reference:
Thread: fn-bea:execute-sql() function vs Oracle JCA Adapter(https://forums.oracle.com/forums/thread.jspa?threadID=2358998&tstart=1275)

Friday, June 08, 2012

OSB - Fault Handling in OSB

Fault Handling in OSB(https://svgonugu.wordpress.com/tag/service-callout/)

OSB - Publish, Routing and Service Callout


1. Service Callout
Used in real time request-response scenarios. Call a service in synchronous way. Being a synchronus call, the thread gets blocked until a response is returned from target service.


2. Publish
Used for Request only scenarios where you don't expect a response back. The nature of Publish action (sync or async) will depend upon the target service you are invoking.

  • Invoking an external service through a business service,  then Publish action with Quality of Service(QoS) as "Best Effort" (default) will work like fire and forget and thread won't get blocked (async call).
  • Invoking a local proxy service (proxy with transport protocol as "local") from another proxy using publish action then it would be a blocking call (synchronus call) and thread will get blocked untill the processing of local proxy finishes.
3. Routing
Only can be created inside a Route Node and Route Node is the last node in a request processing and  not in the pipeline, it passes all processing to another service (business or proxy). A Route Node indicates that Request Processing will end here and Response Processing will begin. You can not have any node after Route Node in the message flow.

Route Node can be seen as an action which defines where a Request thread stops and Response thread begins, in addition to what ever it does. It is know that by-design, request and response pipelines of a OSB proxy will be in different threads unless other wise configured.

Good Practice
Use service callouts for message enrichment or for doing message validation. Use route node to invoke the actual service for which the proxy service is a 'proxy'.

Try to design OSB proxy services in a standard VETO pattern - Validate, Enrich, Transform, rOute. Use Service callout for Validate and Enrich steps and use route node for rOute step. This approach looks more appealing design wise.

Reference:
Thread: compare Routing action versus Service Callout action versus Publish action?
Thread: Route node and Service Call out in OSB




OSB - Upgrade ALSB to OSB



1. XPath namespace prefixes
  <soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="example.com">
   <urn:HouseNumber > 100</urn:HouseNumber>
    . . .
ALSB: select the ‘HouseNumber’ by XPath expression
  $body/ns1:HouseNumber

‘ns1′ is defined to be the correct namespace value “example.com”

OSB: When using very complex XSDs this is not garanteed to work in OSB!

Work Around: Ignore the namespace and use the local-name() function in an XPath expression

  $body/*[local-name()='HouseNumber']


2. XSLT validation in Workspace Studio
XSLT runtime prcessor:

  • ALSB - Xalan XSLT processor
  • OSB   - Saxon XSLT processor (Imports are no longer supported in Saxon.)



In OEPE, the XSLT file validated without any error, thus it still support imports. But the error occurre at runtime.


3. JAXWS
The webservice client upgraded from JAXRPC to JAXWS may not work properly.


References:


Upgrading ALSB services to OSB(http://www.capgemini.com/oracleblog/2011/06/upgrading-alsb-services-to-osb/)

Thursday, June 07, 2012

WebLogic - Work Manager VS Execute Queue



Execute Queue (Earlier Release before WLS 9.0)
  • Different classes of work were executed in different queues, based on priority and ordering requirements, and to avoid deadlocks.
  • Each servlet or RMI request was associated with a dispatch policy that mapped to an execute queue.Requests without an explicit dispatch policy use the server-wide default execute queue.
  • Execute queues are always global.
  • Thread count should be set. Customers defined new thread pools and configured their size to avoid deadlocks and provide differentiated service. It is quite difficult to determine the exact number of threads needed in production to achieve optimal throughput and avoid deadlocks.
Work Managers
  • all Work Managers share a common thread pool and a priority-based queue. The common thread pool changes its size automatically to maximize throughput.
  • Work Managers become very lightweight, and customers can create Work Managers without worrying about the size of the thread pool. 
  • Thread dumps look much cleaner with fewer threads.
  • Possible to specify different service-level agreements (SLAs) such as Fair Shares or Response-Time goals for the same servlet invocation depending on the user associated with the invocation. The requests are still associated with a dispatch policy but are mapped to a Work Manager instead of to an execute queue. 
  • Work Managers are always application scoped. Even Work Managers defined globally in the console are application scoped during runtime. This means that each application gets into own runtime instance that is distinct from others, but all of them share the same characteristics like fair-share goals. 
  • Thread count does not need to be set. WebLogic Server is self-tuned, dynamically adjusting the number of threads to avoid deadlocks and achieve optimal throughput subject to concurrency constraints. It also meets objectives for differentiated service. These objectives are stated as fair shares and response-time goals.

When to Use Work Managers
Following are guildelines to help you determine when you might want to use Work Managers to customize thread management:
  • The default fair share is not sufficient. (This usually ocurrs in situations where one application needs to be given higher priority over another.)
  • A response time goal is required.
  • A minimum thread constraint needs to be specified to avoid server deadlock

Default Work Manager
To handle thread management and perform self-tuning, WebLogic Server implements a default Work Manager. This Work Manager is used by an application when no other Work Managers are specified in the application’s deployment descriptors.

In many situations, the default Work Manager may be sufficient for most application requirements. WebLogic Server’s thread-handling algorithms assign each application its own fair share by default. Applications are given equal priority for threads and are prevented from monopolizing them.

You can override the behavior of the default Work Manager by creating and configuring a global Work Manager called default. This allows you to control the default thread-handling behavior of WebLogic Server.

Global Work Managers
You can create Work Managers that are available to all applications and modules deployed on a server. Global Work Managers are created in the WebLogic Administration Console and are defined in config.xml.

An application uses a globally defined Work Manager as a template. Each application creates its own instance which handles the work associated with that application and separates that work from other applications. This separation is used to handle traffic directed to two applications which are using the same dispatch policy. Handling each application’s work separately, allows an application to be shut down without affecting the thread management of another application. Although each application implments its own Work Manager instance, the underlying components are shared.

Application-scoped Work Managers
In addition to globally-scoped Work Managers, you can also create Work Managers that are available only to a specific application or module. Work Managers can be specified in the following descriptors:
  • weblogic-application.xml
  • weblogic-ejb-jar.xml
  • weblogic.xml
If you do not explicitly assign a Work Manager to an application, it uses the default Work Manager.

A method is assigned to a Work Manager, using the element in the deployment descriptor. The can also identify a custom execute queue, for backward compatibility. 

Work Managers and Execute Queues
This section discusses how to enable backward compatibility with Execute Queues and how to migrate applications from using Execute Queues to Work Managers.

Enabling Execute Queues
WebLogic Server, Version 8.1 implemented Execute Queues to handle thread management which allowed you to create thread-pools to determine how workload was handled. WebLogic Server still provides Execute Queues for backward compaitibility, primarily to facilitate application migration. However, new application development should utilize Work Managers to peform thread management more efficiently.

You can enable Execute Queues in the following ways:
  • Using the command line option -Dweblogic.Use81StyleExecuteQueues=true
  • Setting the Use81StyleExecuteQueues property via the Kernel MBean in config.xml.
When enabled, Work Managers are converted to Execute Queues based on the following rules:

  • If the Work Manager implements a minimum or maximum threads constraint, then an Execute Queue is created with the same name as the Work Manager. The thread count of the Execute Queue is based on the value defined in the constraint.
  • If the Work Manager does not implement any constraints, the the global default Execute Queue is used.

Wednesday, June 06, 2012

WebLogic - Session Monitoring Using WebLogic Diagnostics Framework (WLDF)

It is very helpful to know whether the HttpSession Attributes are Serializable or not. From the AdminConsole you can see the size of HttpSession). If it is negative value, that means the HttpSession contains some non-serializable attributes and your application is not good enough to be deployed on a clustered envs.

What should I do for WLDF?
1. Login to admin console and then create a diagnostic module
    AdminConsole-->Diagnostics-->Diagnostics Modules

  • By clicking New to create a new Diagnostic Module with a name you want, example: MyDiagModule and click OK to save it
  • By clicking  MyDiagModule and navigate to the configuration page of Diagnostic Module. Select the Instrumentation tab and check the checkbox of Enabled and save it
  • By clicking on Targets tab to set the target to cgServer (The target server you want to choose.)

2. Modify your application and add weblogic-diagnostics.xml to the META-INF of your application EAR file.
3. Deploy your application.
4. Login to admin console and fine your application underneath Deployment.
    AdminConsole-->Deployments-->YouApplication --> Configuration --> Instrumentation

  • By clicking your application name to get the setting page of your application
  • Select the Configuration tab and click on the Instrumentation tab, then check the checkbox of Enabled and save it.
  • By clicking the Add Moniter From Libery button, select  HttpSessionDebug and confirm it by clicking OK

NOTE: After done everything mentioned above, please restart the server and make sure it works

Then you can write some code to set some attributes of session, you will be able to see the payload size in the Events Log from AdminConsole.

AdminConsole--> Diagnostics--> Log Files--> EventsDataArchive

weblogic-diagnostics.xml

<?xml version="1.0" encoding="UTF-8"?>
<wldf-resource xmlns="http://www.bea.com/ns/weblogic/90/diagnostics">
<instrumentation>
<enabled>true</enabled>
<wldf-instrumentation-monitor>
<name>HttpSessionDebug</name>
<enabled>true</enabled>
</wldf-instrumentation-monitor>
</instrumentation>
</wldf-resource>




References for WLDF:
Instrumenting Weblogic Applications with WLDF (http://oraclemiddleware.wordpress.com/2012/02/01/instrumenting-weblogic-applications-with-wldf-where-does-the-application-spend-time/)
Instrumenting Java EE applications in WebLogic Server (https://blogs.oracle.com/WebLogicServer/entry/instrumenting_java_ee_applicat)
Session Monitoring Using WLDF (http://middlewaremagic.com/weblogic/?p=450)
Performing Diagnostics in a WebLogic environment (http://middlewaremagic.com/weblogic/?p=6016)