Showing posts with label DB Adapter. Show all posts
Showing posts with label DB Adapter. Show all posts

Saturday, February 28, 2015

Oracle SOA -Payload Size threshold

Oracle JCA Adapters are designed to process large payloads but the BPEL engine consumes huge memory when processing large payloads due to XML conversions which can cause well known OutOfMemory(OOM) and jeopardize the whole system.Setting the payload threshold prevents any data burst from the downstream systems ensuring the JCA Adapters process only payloads that are less than the threshold limit and reject others.

Capping 
the payload size according to  the capacity of the infrastructure in place is always preferred since the servers will take time to recover from OOM error by garbage collection which is a "Stop the World" activity and no requests will be processed by the server during the time.


Maximum Request size for services


The threshold for maximum request size for any exposed service can be set by using this attribute.The value can be set through the EM console by navigating to the service endpoint -> Service/Reference Properties ->Exposed Service. A default value of -1 represents unlimited which can be set in units of bytes,KB,MB or GB to a suitable value that your infrastructure can handle.





This can be restricted at the DMZ level without the requests reaching the web logic servers if the architecture includes any of the below components.



  • Oracle API Gateway
  • Web Server that can restrict request size
  • Load balancer like F5 BIG IP 

payloadSizeThreshold for adapters


Setting the payload threshold ensures that Oracle JCA Adapters rejects payloads greater than the threshold limit. In case of file and FTP adapters when the native size of the payload is not available and if the specific adapter does not use the native translation library, you cannot enforce the payload size threshold limit. For example, in case of xml-debatching, where the Oracle File and FTP Adapters pass a chunk of file content and the actual native size is not known, payload size threshold limit cannot be used.

To set the global property for capping payload size login to the EM console -> soa-infra   -> Administration -> System MBean Browser - > adapter and set the value for DefaultPayloadSizeThreshold . As per the documentation DefaultPayloadSizeThreshold  works only for the inbound adapters.There is no attribute as payloadSizeThreshold which seems to be a bug and DefaultPayloadSizeThreshold works for both inbound and outbound operations.




This threshold can be increased/decreased at adapter service level by overriding the values in composite.xml which takes precedence over the global settings.





 <reference name="insert" ui:wsdlLocation="insert.wsdl">   
 <interface.wsdl interface="http://xmlns.oracle.com/pcbpel/adapter/db/Application3/One2ManyJoining/insert#wsdl.interface(insert_ptt)"/>   
 <binding.jca config="insert_db.jca"/>   
 <property name="payloadSizeThreshold" type="xs:string" many="false" override="may">100</property> </reference>   


Below are some of the options when it is required to process huge data using database  adapter.


  • MaxRaiseSize and MaxTransactionSize can be used while using database polling to restrict the number of records returned from the adapter.
  • Setting the audit level to minimal can enhance  the processing of large data with a drawback of payload not getting saved to the database
  • When processing large payload using XSLT set "streamResultToTempFile" to yes to avoid OutOfMemory error.But assign activities always perform better.
  • Parking Lot pattern can be used to throttle the messages processed.See Throttling in SOA Suite via Parking Lot Pattern at http://www.ateam-oracle.com/throttling-in-soa-suite-via-parking-lot-pattern/  for how to implement in SOA.
Other adapters like AQ,MQ,File,FTP etc... have their own parameters that can be tweaked to control the payload size when used for inbound operations.

Thursday, November 13, 2014

Oracle SOA DB Adapter Fails to return XML Type with MS SQLServer

When you use DB Adapter to access Microsoft  SQL Server Stored Procedures that return output  with XML types, a class type mapping exception can be thrown.

A stack trace similar to the below one can be thrown from the adapter.
Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'Test' failed due to: Unimplemented string conversion. Conversion of JDBC type to String is not supported. An attempt was made to convert a Java object to String using an unsupported JDBC type: . Use a data type with a supported JDBC type. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.


To fix this, change the driver from “com.microsoft.sqlserver.jdbc.SQLServerDriver “  to “weblogic.jdbc.sqlserver.SQLServerDriver “ by logging to the console and changing the driver class name or create a new connection by using of Oracle’s MS SQL server driver.



Also make sure to create a strong schema by introspecting the stored procedure using some input values. If weak schema is used, XML results greater than 2,033 characters in length will be returned  in multiple rows of 2,033 characters each.

For example,
CREATE PROCEDURE [dbo].[spSoaTest] @param1 int AS BEGIN SELECT TOP 500 FROM dbo.TableXX tbl ORDER BY  1 DESC  FOR XML PATH('test'),ROOT('test1'),TYPE END

If you omit the "type" after the "for xml" you may get the below exception while introspecting the stored procedure in JDeveloper.


BINDING.JCA-11819
Database type not supported.
Encountered a database type ntext that is either not supported or is not implemented.
Parameter XML_F52E2B61-18A1-11d1-B105-00805F49916B is of type ntext which is either not supported or is not an implemented datatype.
Check to ensure that the type of the parameter is one of the supported datatypes or that there is a collection or user defined type definition representing this type defined in the database.

                at oracle.tip.adapter.db.sp.xsd.sqlserver.DatabaseBrowser.expandParameter(DatabaseBrowser.java:88)
                at oracle.tip.adapter.db.sp.xsd.sqlserver.DatabaseBrowser.expandParameters(DatabaseBrowser.java:65)

Saturday, September 13, 2014

Oracle SOA / Weblogic 12C - Register new JDBC drivers

We had a requirement to connect to MS SQL server from Oracle SOA Suite 12C using the microsoft JDBC type 4 driver. But while creating the JDBC connection from weblogic console using the ANY type driver available with 12C it was throwing the below error.

Cannot load driver: com.microsoft.jdbc.sqlserver.SQLServerDriver 

As a workaround we wanted to register  Microsoft’s SQL SERVER Driver (Type 4) Version: 2005 and later. Below are the steps we used to register the missing driver. Although weblogic comes with most of the drivers by default, We can register any third party driver supported by weblogic using the below steps.

Oracle SOA 12C connect to MS SQL server

1. Download the Microsoft JDBC driver  for MS SQL server (sqljdbc4.jar) from http://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx

2.Copy the jar file to the weblogic lib folder ${WL_HOME}/SERVER/lib.The jar file should be available in all the managed servers to which the datasource will be targeted.

3.Add the path to the WEBLOGIC_CLASSPATH in the commEnv.sh located in the ${WL_HOME}/common/bin/commEnv.sh. You can verify if the jar was included to calsspath in the logs during server start up. 

4. To update the list of drivers weblogic navigate to ${WL_HOME}/server/lib and add the below entry to the jdbcdrivers.xml.

<Driver
Database="MS SQL SERVER"
Vendor="Microsoft"
Type="Type 4"
DatabaseVersion="2005 and later"
ForXA="false"
ClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
URLHelperClassname="weblogic.jdbc.utils.MSSQL2005JDBC4DriverURLHelper"
TestSql="SELECT 1">
<Attribute Name="DbmsName" REQUIRED="false" InURL="true"/>
<Attribute Name="DbmsHost" REQUIRED="true" InURL="true"/>
<Attribute Name="DbmsPort" Required="true" InURL="true" DefaultValue="1433"/>
<Attribute Name="DbmsUsername" Required="true" InURL="false"/>
<Attribute Name="DbmsPassword" Required="true" InURL="false"/>

</Driver>

Restart the servers and the new driver should be available as below.


Oracle SOA 12C - Migrating projects with DB adapter returning XMLTYPE

While migrating SOA composites containing DB adpaters which calls stored procedures in Oracle database returning XMLTYPE from SOA suite 11g to 12c an error similar to the below may be noticed.


</faultType> 
-<bindingFault xmlns="http://schemas.oracle.com/bpel/extension"> 
-<part name="summary"> 
<summary> 

Exception occurred when binding was invoked. 
Exception occurred during invocation of JCA binding: "JCA Binding execute of Reference operation '*******' failed due to: Object XML conversion error. 
An error occurred while converting a Java object to XML. 
Unable to convert the XSD element ***** whose JDBC type is OPAQUE to a corresponding XML document element. Cause: java.lang.ClassCastException: weblogic.jdbc.wrapper.WrapperSQLXML_oracle_xdb_XMLType cannot be cast to oracle.sql.OPAQUE 
Analyze the error and correct if possible. Contact oracle support if error is not fixable. This exception is considered not retriable, likely due to a modelling mistake. 
". 
The invoked JCA adapter raised a resource exception. 
Please examine the above error message carefully to determine a resolution. 

</summary> 
</part> 
-<part name="detail"> 
<detail> 

weblogic.jdbc.wrapper.WrapperSQLXML_oracle_xdb_XMLType cannot be cast to oracle.sql.OPAQUE 

</detail> 
</part> 
-<part name="code"> 
<code> 

null 

</code> 
</part> 
</bindingFault> 
</bpelFault>
 

The problem is that in 11G the wizard creates the schema elements as SYS.XMLTYPE for XML type parameters whereas in 12C it should be PUBLIC.XMLTYPE.So changing this in database adapter schema will resolve the issue.

For example,

from

<complexType> 
<sequence> 
<element name="P_XML_VALUE" type="db:SYS.XMLTYPE" db:index="2" db:type="Opaque" minOccurs="0" nillable="true"/> 
</sequence> 
</complexType>

to


<complexType> 
<sequence> 
<element name="P_XML_VALUE" type="db:PUBLIC.XMLTYPE" db:index="2" db:type="Opaque" minOccurs="0" nillable="true"/> 
</sequence> 
</complexType>



Monday, July 8, 2013

DB Adapter fails to return nVarchar Type from stored procedure with MS SQLServer 2005

When you are using DbAdapter to access MS SQLServer 2005 Stored Procedures that return resultsets as dynamic row sets with nVarchar column types, a class type mapping exception is thrown.

You will see a stack trace as follows:

<faultstring>Exception occured when binding was invoked.
Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation '***' failed due to: Unimplemented string conversion.
Conversion of JDBC type to String is not supported.
An attempt was made to convert a Java object to String using an unsupported JDBC type: .
Use a data type with a supported JDBC type.
".
The invoked JCA adapter raised a resource exception.
Please examine the above error message carefully to determine a resolution.</faultstring>


The issue can be resolved by switching the driver from  com.microsoft.sqlserver.jdbc.SQLServerDriver c to weblogic.jdbc.sqlserver.SQLServerDriver


But there is a limitation of maximum size  4000 characters that can be returned by any column of the stored procedure while using this driver.