Wednesday, October 16, 2019

12c OSB Throttling

What is Throttling:
Throttling is termed as "regulate the flow". Oracle Service Bus has throttling feature and by using that feature we can control number of requests sent to target service.

Why we need OSB throttling:
Every system has its own capacity means it can process only certain number of message at one time, if we try to send messages beyond its capacity then that system's performance can degrade or in worst case it can crash. So to avoid all this we can use OSB throttling feature to send limited messages to target system.

In oracle Service bus we have two approaches to resolve these kind of errors:
  • Throttling in Business Services
  • Work Managers
By using throttling in business service we can restrict the no of requests to target system.

Here I will show the Throttling setups in Business Service.
Contents:
  1. Create a Service bus application, project, proxy schema, WSDL and Proxy service.
  2. Create Business Service
  3. Create the XQUERY mapping for request response.
  4. Service callout to the created business Service and mapping request response
  5. Setup the throttling from EM console.
  6. Load test from SOAP UI tool.
Create a Service bus project, proxy schema, wsdl and Proxy service.
Click here 12c-osb-create-wsdl-proxy to know how to create service bus project, proxy wsdl and proxy service.

I have created a SOA hello World service which i will call as business wrapper service.
http://hostname:8001/soa-infra/services/POC/HelloWorldProject/helloworldlprocess_client_ep?WSDL
Create business service











Create XQUERY mapping files:













Same way create the response mapping


Service callout to the created business service and use the created request and response mappings.











Set up the throttling settings from EM console:
EM Console⇾Target Navigation⇾SOA⇾Service-bus (AdminServer)⇾Select the service bus project⇾Go to Operations tab⇾click the business service⇾Enable throttling state and Maximum Concurrency, Throttling Queue and Time to Live values for throttling.




Maximum Concurrency: The maximum number of records that the business service can process simultaneously. This value can not be 0 (zero); it must be a positive integer.
Throttling Queue: The maximum number of messages in the Throttling Queue or Throttling Queue. A value of 0 indicates that there is no Throttling Queue.
Time to Live: The number of milliseconds that a message can be in the queue before expiration. A value of 0 means that messages do not expire.

If you no longer want to limit messages for a business service, you can disable throttling for this service at any time. When you disable throttling, the messages are processed normally and the message flow is no longer limited by the throttling settings.
To disable the throttling for a business service, uncheck the Throttling state box.

Load test from SOAP UI:
Created service bus URL:
http://hostname:2001/ThrottlingSBProject/proxyServices/EmployeeProxyService?wsdl
File⇾New SOAP Project
 Put the WSDL url in the initial WSDL and give a project name
right click on the created Request⇾Add to Test case
Provide a test suite name
Provide a test case name

Right click on Load tests⇾New Load Test
Provide the Load test name
Configure the load test parameters as required. here I send 20 requests as total runs.
 You can see 3 requests hit the service at a time.

Tuesday, October 15, 2019

12c OSB - create a WSDL based on a XSD and proxy service on the created WSDL.

Here I will show you how to create a synchronous WSDL based on a request-response schema and then to create a proxy service based on the created WSDL.

First create an application with the service bus project(if application is not created).



 Create a folder structure to hold all the services and resources.


I will use the following schema to create the WSDL.
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.emp.test"
            targetNamespace="http://www.emp.test" elementFormDefault="qualified">
        <xsd:element name="Request">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="EmployeeName" type="xsd:string"/>
              <xsd:element name="EmployeeId" type="xsd:string"/>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
        <xsd:element name="Response">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="HellowOutput" type="xsd:string"/>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
</xsd:schema>

Right click on WSDL folder⇾New⇾WSDL(Builder)

Provide the WSDL Name, operation, binding and portType names and chose the Interface type.
Setup Input and output using the XSD.


Same way add the message part for Output.


WSDL is ready.Now create the Proxy service.
Choose WSDL Definition and browse the WSDL

Keep the Generate pipeline checked in to create the pipeline with the Proxy.




Friday, October 11, 2019

12c OSB - split large xml files

Requirement:
In current process, Source application sends New hire and change employee data into a apps DB. OSB service pulls the large payload (>2K employee elements) using apps adapter and sends the data as single instance to SOA service which again push the data in a JMS queue from where soa service pulls the data and sends to the EDN as events to a default JMS queue from where all the subscribing event composites processing the data.

Cons: This huge payload is processing as a single instance payload through soa service and this is taking huge time to process and the instance is also not loaded/not opening.

Solution:
Now we are splitting the large payload into smaller chunks of batches (each batch size =500 employee elements) and write them in a directory using JCA based file adapter. Then using another proxy service we are reading all the files in 10 mins interval and then sends to SOA service.

Pros: This has resolved “the instance in not loading/opening issue”. Now all instances are getting loaded/opened with success.   

Pipeline flow :



Activity wise Split logic explained:

1.Assign: Take a batch Load
Value: number('500')
Variable: batchLoad
2.Assign: Count total employees
Value: fn:count($body/emp:WF_EVENT_T/EVENT_DATA/hrms_event_data/employee_data/employee)
Variable: varTotalEmpCounts

3.Assign : Taking the number of batches or iteration
fn:ceiling(xs:int($varTotalEmpCounts) div number($batchLoad))
varIterationCount
4.Assign: Taking the body payload into a tempBody variable
5.Delete: Emptying the employee elements from the tempBody. This way it is keeping the header and other elements.Only employee elements are deleted.
6.Assign: Now assigning the emptied employee elements into 2nd tempBody2 variable.
7.Assign: Taking an initial batch count
8.For Each: For each employee we are now adding the the employee into the tempBody variable until the batch size(500) meets.
9.Insert: employees into the tempBody variable
10. IF: Below is the condition to stop the for each loop once the batch size meets:
$varIndex = (number($batchLoad) * number($batchCount)) or
$varIndex = $varTotalLoopCount
11.Publish: Publish the batch in a file directory.
12.Replace:
13.Assign: then again assign tempbody2 payload into the tempBody variable
14.Assign: Then increasing the batch count

File Write JCA:
<adapter-config name="fileWrite" adapter="file" wsdlLocation="../WSDL/fileWrite.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
  <connection-factory location="eis/FileAdapter"/>
  <endpoint-interaction portType="Write_ptt" operation="Write">
    <interaction-spec className="oracle.tip.adapter.file.outbound.FileInteractionSpec">
      <property name="PhysicalDirectory" value="/soashare/abc/fileIn"/>    
      <property name="Append" value="false"/>
      <property name="FileNamingConvention" value="Employee%yyMMddHHmmssSS%.xml"/>
      <!--<property name="SingleThreadModel" value="true"/>-->
    </interaction-spec>
  </endpoint-interaction>

</adapter-config>

File Read JCA:
<adapter-config name="fileReadService" adapter="file" wsdlLocation="../WSDL/fileReadService.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
  <connection-factory UIincludeWildcard="*.xml" location="eis/FileAdapter"/>
  <endpoint-activation portType="Read_ptt" operation="Read">
    <activation-spec className="oracle.tip.adapter.file.inbound.FileActivationSpec">
      <property name="PhysicalDirectory" value="/soashare/abc/fileIn"/>
      <property name="PhysicalArchiveDirectory" value="/soashare/abc/archive"/>
      <property name="UseHeaders" value="false"/>
      <property name="MinimumAge" value="0"/>
      <property name="Recursive" value="false"/>
      <property name="PollingFrequency" value="600"/>
      <property name="MaxRaiseSize" value="1"/>
      <property name="SingleThreadModel" value="true"/>
      <property name="DeleteFile" value="true"/>
      <property name="IncludeFiles" value=".*\.xml"/>
    </activation-spec>
  </endpoint-activation>
</adapter-config>

Function of <property name="SingleThreadModel" value="true"/>
You want to configure File Adapters that it should pick one file at time from the given location with given polling interval.

Solution :
You set the "SingleThreadModel" and "MaxRaiseSize" properties for your file adapter.
Edit the adapter's jca file and add the following properties:
property name="SingleThreadModel" value="true"
property name="MaxRaiseSize" value="1"

Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...