Showing posts with label SOA 11g. Show all posts
Showing posts with label SOA 11g. Show all posts

Tuesday, 29 November 2016

JCA Adapters Tips & Tricks


Oracle Fusion Middleware

JCA Adapters Tips & Tricks

In This post, I want to list important JCA adapter properties, which are really helpful in real-time projects.

Assumption: In this post, when I use a word called "CLUSTER", it contains one Admin server and two SOA Managed servers. Two Managed servers which are running, in two physical machines.

File Adapter:  

Tip1: 

If we are using File polling Adapter in clustered SOA domain then we have to use HA File adapter JNDI (eis/HAFileAdapter).
We should edit one property in HA File adapter JNDI. That is "controlDir" property in HAFile adapter JNDI as shown in below image.
image1(HA File Adapter Properties):
 
image2(HA File Adapter Properties):
If we don't configure controlDir property, then two SOA managed server will poll one file two times. To avoid duplicate file processing we have to configure controlDir property.  
We can expect same behavior and configuration for HA FTP Polling adapter.

NOTE: controlDir property value (path) should be mounted between two physical machines as shared folder.
image3(HA FTP Adapter Properties):  
 

Tip2:  

By default File Adapter will read multiple files from inbound folder in one polling. 
Actually there is no limit that how many files should be processed in one polling.
If you want to control total number of files to be processed in one polling then we have to set below two properties in JCA file (Open file polling adapter .jca file and manually we have provide these properties).
<property name="SingleThreadModel" value="true"/>
<property name="ThreadCount" value="4"/>


As per the above example, 4 threads will be created and only 4 files will be processed in one polling

FTP Adapter: 

Tip1: 

By default FTP polling adapter will create archive file in local folder of SOA server physical machine. If we want to archive FTP file in FTP location then we have to set below FTP adapter jca property.

NOTE: But we cant set this property in design time(jca file in JDeveloper). It is possible to set only at run time in enterprise manager(jca service adapter properties in EM).
Navigation: develop SOA project by using FTP adapter -->deploy SOA project --> login into EM --> single click on our SOA project --> scroll down dashboard tab --> click on FTP polling adapter --> properties tab -->
a. click add button -->  add new property --> "UseRemoteArchive" as "true"
b. fileArchivePath --> path should be available in FTP location.

Database Adapter:

Tip1:

In SOA Clustered environment, if we configure DB polling adapter then we have to enable singletone property in .jca file as below.If we don't configure this property then DB polling adapter(2 SOA managed servers) will try to read duplicate records from source table. 


Tip2:
Few important jca properties in DB polling adapter.
Database Rows Per XML Document: <property name="MaxRaiseSize" value="6"/>
Database Rows Per Transaction: <property name="MaxTransactionSize" value="15"/>
DB adapter will not process all records as one unit. DB adapter will debatch table into sub parts with the help of above properties.

"TABLE" will be divided into sub parts, each sub part is called as "TRANSACTIONS"
"TRANSACTION" will be divided into sub parts, each sub part is called as "XML Documents"
Each "XML Document" will be processed as one SOA instance.

If we configure above two properties in a DB polling adapter then we can expect below behaviour.
Ex: Assume, DB Table has 50 records, MaxTransactionSize set as 15 and MaxRaiseSize set as 6.
Now the way of execution is as below.

Table with 50 records will be divided into 4 transactions.
transaction1 has 15 records
transaction2 has 15 records
transaction3 has 15 records
transaction4 has 5 records (observe only 5 records in last transaction)  

Now TRANSACTIONS should be divided into XML Documents.
Transaction1 devided into 3 XML Documents.
            XML Document1 has 6 records
            XML Document2 has 6 records
            XML Document3 has 3 records (Observer only 3 records in last XML Document.)         
Transaction2 devided into 3 XML Documents.
            XML Document1 has 6 records
            XML Document2 has 6 records
            XML Document3 has 3 records (Observer only 3 records in last XML Document.) 
Transaction3 devided into 3 XML Documents.
            XML Document1 has 6 records
            XML Document2 has 6 records
            XML Document3 has 3 records (Observer only 3 records in last XML Document.)  
Transaction4 devided into 1 XML Documents.
            XML Document1 has 5 records (Observer only 1 XML Document with 5 records.)

Finally, above table will be divided into total 10 sub parts and we are calling these sub parts as XML Documents. As i mentioned above 10 XML Documents will be processed as 10 SOA instances.

NOTE: Here very important point we need to observer. All these 10 SOA instances will be processed parallel in one polling.

If you don't want to process all XML Documents in one polling then we can control processing behavior by setting below property in .jca file.
 <property name="NumberOfThreads" value="1"/>
If Value is 1, it means only one XML Document  will be processed in one polling. 10 XML Documents will be processed in 10 sequential polling's.

  
NOTE: If you like this post or if you have any unresolved jca properties, feel free to comments here.

Saturday, 25 October 2014

File Adapter MOVE operation in Oracle SOA 11g

File Adapter MOVE operation in Oracle SOA Suite 11g

The Oracle File and FTP Adapters let you copy or move a file from one location to another, or delete a file from the target directory. Additionally, the Oracle FTP Adapter lets you move or copy files from a local file system to a remote file system and from a remote file system to a local file system. This feature is implemented as a interaction specification for outbound services. So, this feature can be accessed either by using a BPEL invoke activity or a Mediator routing rule.

Step 1 :
Drag drop file adapter in reference pane of composite.xml

Setp 2:
In file adapter wizard perform below steps.

In wizard step4 we have to select Synchronous Read File
NOTE : You have selected Synchronous Read File as the operation because the WSDL file that is generated because this operation is similar to the one required for the file I/O operation.

provide your own name as per naming convention which you follow.
In my case i provided "FileMove" as move operation name.

Enter a dummy physical path for the directory for incoming files, and then click Next. The File name page is displayed.
Note: The dummy directory is not used. You must manually change the directory in a later step.

Enter a dummy file name, and then click Next. The Messages page is displayed.

Note: The dummy file name you enter is not used. You must manually change the file name in a later step.
Select Native format translation is not required (Schema is opaque), and then click Next. The Finish page is displayed.
Note: we are planning to perform move operation so we no need to process the payload. For this reason no need to create an XSD.



Step 3:
now open file adapter .jca file which looks as below.

=====================================================================
<adapter-config name="FileAdptMoveTest" adapter="File Adapter" wsdlLocation="FileAdptMoveTest.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
 
  <connection-factory location="eis/FileAdapter"/>
  <endpoint-interaction portType="FileMove_ptt" operation="FileMove">
    <interaction-spec className="oracle.tip.adapter.file.outbound.FileReadInteractionSpec">
      <property name="DeleteFile" value="true"/>
      <property name="PhysicalDirectory" value="C:/Dummy path"/>
      <property name="FileName" value="dummyFileName.txt"/>
    </interaction-spec>
  </endpoint-interaction>
</adapter-config> =====================================================================

Step 4:

Now replace <endpoint-interaction>-----</endpoint-interaction> with below code.
<interaction-spec className="oracle.tip.adapter.file.outbound.FileIoInteractionSpec">
      <property name="SourcePhysicalDirectory" value="foo1"/>
      <property name="SourceFileName" value="bar1"/>
      <property name="TargetPhysicalDirectory" value="foo2"/>
      <property name="TargetFileName" value="bar2"/>
      <property name="Type" value="MOVE"/>
</interaction-spec>

After the change in .jca file, it should looks as below.
=================================================================
<adapter-config name="FileAdptMoveTest" adapter="File Adapter"
                wsdlLocation="FileAdptMoveTest.wsdl"
                xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
    <connection-factory location="eis/FileAdapter"/>
    <endpoint-interaction portType="FileMove_ptt" operation="FileMove">
        <interaction-spec className="oracle.tip.adapter.file.outbound.FileIoInteractionSpec">
            <property name="SourcePhysicalDirectory" value="C:\Users\Fusion\Desktop\source"/>
            <property name="SourceFileName" value="student.txt"/>
            <property name="TargetPhysicalDirectory" value="C:\Users\Fusion\Desktop\target"/>
            <property name="TargetFileName" value="studentNew.txt"/>
            <property name="Type" value="MOVE"/>
        </interaction-spec>
    </endpoint-interaction>
</adapter-config>
=================================================================
Note : Note: You have modified the className attribute, and added SourcePhysicalDirectory, SourceFileName,TargetPhysicalDirectory, TargetFileName and Type.  The Type attributes decides the type of operation. Apart from MOVE, the other acceptable values for the Type attribute are COPY and DELETE.

Note :  SourceFileName and TargetFileName no need to be same. we can provide different file names.

Note : Currently, the values for the source and target details are dummy. You must populate them at run-time with .The source and target details are hardcoded in the preceding example. You can also provide these details as run-time parameters.

       (a) create 4 string variables in BPEL.
                   <variable name="sourceDirectory" type="xsd:string"/>
                   <variable name="sourceFileName" type="xsd:string"/>
                   <variable name="targetDirectory" type="xsd:string"/>
                   <variable name="targetFileName" type="xsd:string"/>
            Note: Make sure about namespace in .bpel file. Just cross check below namespace is available  in .bpel or not.
                      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      (b) get the source and target folder path , source and target file name from any source. Like recieve activity input variable or from a DVM or from a table. Some how get the required date and by using Assign activity copy the data from proper source to newly created variables.


Step 5:
Now open .bpel source view.
Add custom properties in invoke activity.

Existing code:
 <invoke name="Invoke1" inputVariable="Invoke1_FileMove_InputVariable"
                outputVariable="Invoke1_FileMove_OutputVariable"
                partnerLink="FileAdptMoveTest" portType="ns1:FileMove_ptt"
                operation="FileMove" bpelx:invokeAsDetail="no"/>

Modified Code:
 <invoke name="Invoke1" inputVariable="Invoke1_FileMove_InputVariable"
                outputVariable="Invoke1_FileMove_OutputVariable"
                partnerLink="FileAdptMoveTest" portType="ns1:FileMove_ptt"
                operation="FileMove" bpelx:invokeAsDetail="no">
<bpelx:inputProperty name="jca.file.SourceDirectory" variable="sourceDirectory"/>
<bpelx:inputProperty name="jca.file.SourceFileName" variable="sourceFileName"/>
<bpelx:inputProperty name="jca.file.TargetDirectory" variable="targetDirectory"/>
<bpelx:inputProperty name="jca.file.TargetFileName" variable="targetFileName"/>
</invoke>

sourceDirectory, sourceFileName, targetDirectory and targetFileName are string variables which we created in Step4.

NOTE : above properties syntax is related to bpel 1.1 version.