Monday, December 10, 2012

OFMW11. Timeout...

OFMW11. Timeout...
At server level there are some parameters which are quite important and useful; one of them is related to Timeout.
Now definition of timeout is quite simple when you are making any http/https/rmi etc connection you can specify the timeout parameter which means after establishing a connection, if transaction is taking more time than configured timeout value then transaction should get timeout. This is important to implement because it’s prevent long-running processes from holding resources over an extended period of time.
I am going to talk about timeout parameters which are existing in OFM11g at various places and their meaning and relations.
SOA server’s timeout configuration –
There are multiple places where you can set the timeout for SOA servers.

1         SyncMaxWaitTime:

The SyncMaxWaitTime property applies to durable synchronous processes having breakpoint activities which forces dehydration.
For this parameter you have concentrate more in details because I have seen lots of audience that have wrong understanding for this parameter.
First of all this parameter only for the Synchronous process with breakpoint activities e.g. receive (except first one), pick (onAlarm, onMessage), wait, reply and checkpoint etc. This configuration is not for the asynchronous process since in case of async BPEL no receiver thread is waiting to timeout.
Another mistake I have noticed the users trying to co-relate this parameter for the synchronous transaction to the external system from Asynchronous BPEL/composite process. Users expect a Sync invocation to external system Webservice should timeout if it’s taking more time than configure for SyncMaxWaitTime period.  This parameter is not applicable for this scenario, try to implement httpReadTimeout and httpConnTimeout property within composite itself, later describe in this post.

Example of Sync BPEL Process with Breakpoint Activities -
<receive name="receiveInput" partnerLink="client" variable="input"
createInstance="yes" />
<wait for="'PT10S'" />
<reply name="replyOutput" partnerLink="client" variable="output" />
For details understanding for this parameter, how engine level its works, please refer the below URL

1.1       Steps to modify the SyncMaxWaitTime –

1)      Login into EM console
2)      Expand SOA and right click on "soa-infra" and select: SOA Administration -> BPEL Properties
3)      Click on "More BPEL Configuration Properties" link and Locate syncMaxWaitTime(default 45 second) and change it.

2         BPEL Engine Time: 

There are many BPEL engine EJB’s exist in “soa-infra” Enterprise application which process the message during runtime, each EJB has its own timeout parameter which need to configure and should be in relation with JTA and SyncMaxWaitTime.

2.1       Steps to modify the BPEL Engine EJBs timeout–

1)      Log into Oracle WebLogic Administration Console
2)      Click Deployment and find out ‘soa-infra” Enterprise application, stop this application forcefully.
3)      Click on this application soa-infra -> list of EJBs will be appeared.
4)      Following EJBs need to be updated
Ø  BPELActivityManagerBean
Ø  BPELDeliveryBean
Ø  BPELDispatcherBean
Ø  BPELEngineBean
Ø  BPELFinderBean
Ø  BPELInstanceManagerBean
Ø  BPELProcessManagerBean
Ø  BPELSensorValuesBean
Ø  BPELServerManagerBean

5)      Change the parameter in the Configuration tab for the Transaction Timeout setting(default 300 sec for most of EJBs).
6)      Click Save.
7)      Save the Plan.xml to some known location - Ensure no other file is named Plan.xml -.
8)      Restart the  SOA servers and start this application back.

3         JTA:

This is timeout which a weblogic server allows to wait for a transaction to be complete in first phase for 2 phase transaction which is getting used for distributed transactions.

3.1       Steps to modify the JTA Timeout in Weblogic–

1)      Log into Oracle WebLogic Administration Console.
2)      Click on your ‘domain name’ in console
3)      Go to JTA tab page
4)      Change the value of Timeout Seconds (the default is 30).
5)      Click Save.
6)      Restart Oracle WebLogic Server.

4         Webservice Read and connection timeout:

When a http request been made to external system using web service 1) httpReadTimeout 2) httpConnTimeout and 3) optimization properties can be used to timeout that transaction, values are in milliseconds and this configuration only applicable for http protocol based web service invocation.
Modify the composite.xml for the service for which timeout has to set-
<reference name="Service1"
<interface.wsdl interface=""/>
< port=""
<property name="oracle.webservices.local.optimization">false</property>
<property name="oracle.webservices.httpReadTimeout" type="xs:string"
<property name="oracle.webservices.httpConnTimeout" type="xs:string" many="false">5000</property>

oracle.webservices.local.optimization parameter value could be true/false, make it false if service which user is going to invoke reside in same Weblogic Instance to avoid execution of SOAP stack
In the BPEL process you can add a Catch branch for a RemoteFault if you want to catch this error.
Note when using this parameter it will return a "bpelx:timeout" Fault, and not a RemoteFault. It's possible to use this setting for Invoke or Receive activities.
Refer the Oracle Note ID 979683.1 for more details

5         Relation between timeouts

If the invocation pattern is like this-
Request   - Consumer invokes >> SOA Load balancer >> SOA Managed Server >> Provider System
Response - Consumer invokes << SOA Load balancer << SOA Managed Server << Provider System
Consumer system/API Timeout >> SOA Load Balancer Timeout (If Present) >> Global Transaction Timeout JTA >> BPEL EJB's transaction timeout >> syncMaxWaitTime OR composite Level Timeout >> Provider System/API timeout

6         Weblogic Server Timeout parameters 10.3.6.

There are few more parameters related to timeout which probably you might consider to revisit during problem or to improve your performance.

6.1       Weblogic Console>> DomainName>>Environment >>Servers>>click on particular server>>Protocal tab page >>General tab page:

6.1.1    Complete Message Timeout:       

The maximum number of seconds that this server waits for a complete message to be received.

6.1.2     Idle Connection Timeout:

The maximum number of seconds that a connection is allowed to be idle before it is closed by the server.

6.1.3     Tunneling Client Timeout:

The amount of time (in seconds) after which a missing tunneled client is considered dead.

6.2       Weblogic Console>> DomainName>>Environment >>Servers>>click on particular server>>Protocal tab page >>HTTP tab page:

6.2.1     Post Timeout:

Timeout (in seconds) for reading HTTP POST data in a servlet request. If the POST data is chunked, the amount of time the server waits between the end of receiving the last chunk of data and the end of receiving the next chunk of data in an HTTP POST before it times out.

6.2.2     Duration:

The amount of time this server waits before closing an inactive HTTP connection.

6.2.3     Tunneling Client Timeout:

The amount of time (in seconds) after which a missing tunneled client is considered dead.

6.3       Home >Summary of JDBC Data Sources >SOADataSource>> Transaction Tab page

6.3.1     XA Transaction Timeout:

The number of seconds to set as the transaction branch timeout.
If set, this value is passed as the transaction timeout value in the XAResource.setTransactionTimeout() call on the XA resource manager, typically the JDBC driver.
When this value is set to 0, the WebLogic Server Transaction Manager passes the global WebLogic Server transaction timeout in seconds in the method.
If set, this value should be greater than or equal to the global WebLogic Server transaction timeout.
Note: You must enable XaSetTransactionTimeout to enable setting the transaction branch timeout

6.4       Home >Summary of JDBC Data Sources >SOADataSource >> Connection Pool Tab page

6.4.1     Inactive Connection Timeout:

The number of inactive seconds on a reserved connection before WebLogic Server reclaims the connection and releases it back into the connection pool.
You can use the Inactive Connection Timeout feature to reclaim leaked connections - connections that were not explicitly closed by the application. Note that this feature is not intended to be used in place of properly closing connections.
When set to 0, the feature is disabled.

6.4.2     Connection Reserve Timeout:

The number of seconds after which a call to reserve a connection from the connection pool will timeout.
When set to 0, a call will never timeout.
When set to -1, a call will timeout immediately.

6.4.3     Statement Timeout:

The time after which a statement currently being executed will time out.
StatementTimeout relies on underlying JDBC driver support. WebLogic Server passes the time specified to the JDBC driver using the java.sql.Statement.setQueryTimeout() method. If your JDBC driver does not support this method, it may throw an exception and the timeout value is ignored.
A value of -1 disables this feature.
A value of 0 means that statements will not time out

6.5       Connection Factory Timeout:

If you have implemented the JMS in your project, then there must be a connection factory exist to locate JMS queue, each connection factory has its own timeout-
Weblogic Admin Console>>Home>>JMS Module>>(Your JMS Module)>>(connection Factory Name)>> Transaction Tab page

6.5.1     Transaction Timeout:

The timeout value (in seconds) for all transactions on connections created with this connection factory.
If a transacted session is still active after the timeout has elapsed, the transaction is rolled back. A value of 0 indicates that the default value will be used. If you have long-running transactions, you might want to adjust the value of this attribute to allow transactions to complete.