Tuesday, September 3, 2019

12c SOA Event Delivery Network (EDN)

EDN uses JMS to deliver events from subscribers to publishers, but the configuration of JMS queues and topics and any associated filters is hidden from users of the EDN Service.

Advantages:
  1. When an event is published, it will be published in the entire domain. This means you can publish an event in one composite and subscribe to it in an other composite. You can subscribe to an event from another composite by browsing to its .edl file when adding the event to your mediator.
  2. You can play around with the consistency of the event when you subscribe to it. You can choose one of three: One and Only one, Guaranteed & Immediate.
In 11g ⇾
EDN uses DB AQ by default for publish and subscribe model of business events. This can be confirmed by verifying value of MBean property EdnJmsMode.
    False value denotes EDN using DB AQ
    True value denotes EDN using Weblogic JMS.
You can verify by navigating to oracle.as.soainfra. config –> SoaInfraConfig –> soa-infra in Application Defined MBeans.

In 12c ⇾
EDN uses Weblogic JMS by default. This can be confirmed by verifying value of MBean property JmsType .
    WLJMS value denotes EDN  using Weblogic JMS
    AQJMS value denotes EDN using AQ DB .
You can verify by navigating to oracle.as.soainfra.config –> EDNConfig –> edn in Application Defined MBeans

We will create following way of publishing and subscribing the events:
  1. BPEL based
  2. Mediator based
Through BPEL Implementation:
Step1: Create a XSD which we need to generate event definition (.edl) file.

XSD code:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.emp.sample"
            targetNamespace="http://www.emp.sample" elementFormDefault="qualified">
  <xsd:element name="EmployeeRoot">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="Employee" maxOccurs="unbounded" minOccurs="0">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="Name" type="xsd:string"/>
              <xsd:element name="Id" type="xsd:string"/>
              <xsd:element name="Type" type="xsd:string"/>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

Step2: Create a EDL file using the created xsd.










Step3: Create BPEL to publish the event.



In the BPEL, drag and drop invoke activity and choose Interaction type as event.


Choose the event and variable name.







Step4: Subscribe event through BPEL





Now deploy and test.

Through Mediator Implementation:

Step1: Create XSD to generate the event definition to be used in the EDN.

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.emp.sample"
            targetNamespace="http://www.emp.sample" elementFormDefault="qualified">
  <xsd:element name="EmployeeRoot">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="Employee" maxOccurs="unbounded" minOccurs="0">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="Name" type="xsd:string"/>
              <xsd:element name="Id" type="xsd:string"/>
              <xsd:element name="Type" type="xsd:string"/>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

Step2: Create Event definition using the created XSD.









Step3: Create a mediator to publish the event.












Step4: Subscribe the event






Now deploy to EM console and test.


Monday, September 2, 2019

Topics vs Queues

Topics:
  • A JMS Topic implements publish and subscribe semantics.
  • When you publish a message it goes to all the subscribers who are interested - so zero to many subscribers will receive a copy of the message.
  • Only subscribers who had an active subscription at the time the broker receives the message will get a copy of the message.
    Topics = Insert > Broadcast (send to all subscribers) 1:n

Queues:
  • A JMS Queue implements load balancer semantics. 
  • A single message will be received by exactly one consumer. 
  • If there are no consumers available at the time the message is sent it will be kept until a consumer is available that can process the message. If a consumer receives a message and does not acknowledge it before closing then the message will be redelivered to another consumer. 
  • A queue can have many consumers with messages load balanced across the available consumers.
    Queues = Insert > Withdraw (send to single subscriber) 1:1

Queues vs Topics



Oracle 12c SOA Suite - composites lazy loading

Introduction:
A new feature in SOA Suite 12c is composite lazy loading.
  • This feature allows the components, WSDLs, and XSDs for a composite to be loaded as needed instead of at startup. 
  • In SOA Suite 11g, we observed that Server start up taking time when we have more numbers of composites deployed on the server. Many of the composites may be retired or previous versions simply for maintaining compatibility.  
  • Once utilizing SOA 12c, those customers will no longer have slow server start up times and can accomplish restarts much more quickly with less downtime for each node.
  • This helps to reduce start up time of the SOA servers from possibly as high as 30 minutes for domains with a large number of composites deployed, down to just a few minutes.
Lazy Loading Levels:
Composite Lazy Loading can be configured at two levels:
  1. Domain Level
  2. Component Level
Lazy Loading at Domain Level:
This setting can be disabled/enabled from System MBean Browser in FMW EM console.

1. Login to EM Console, right-click on the domain you want to tune and select System MBean Browser from the drop-down menu.



2. In the System MBean Browser folder structure, navigate through: Application Defined MBeans --  oracle.as.soainfra.config -- Server: ServerName -- SoaInfraConfig -- soa-infra.



3. When you click on soa-infra, its attributes will be listed in on the right. Look for the CompositeLazyLoading attribute and click on it. You can set the value to true to enable it or
false to disable it.

4. Click Apply and restart the server for changes to take effect.

Lazy Loading at the Component level:
To enable/disable it at component level, you need to follow below steps:
1. Open composite.xml file
2.  Add the new property lazyLoading="false" to override the default behavior at the domain level, as shown in screen shot
Component level

3. Redeploy your code

By default, composites will inherit the lazy loading setting from the domain level.

12c SOA BPEL - Process Large Files Using Oracle File Adapter Chunked Read Option


Introduction: SOA 12c adds a new feature ChunkedRead operation to the JCA File Adapter. Prior to this, users had to use a SynchRead operation and then edit the JCA file to achieve a "chunked read". In this blog, I will attempt to explain how to process a large file in chunks using the SOA File Adapter.

Advantage: Chunking large files reduces the amount of data that is loaded in memory and makes efficient use of the translator resources.

Here we will poll a large CSV file having 12 number of records.

Step1: Create a file adapter
Drag & drop a File adapter to the external references swimlane of our SOA composite. Follow instructions in the wizard to complete the configuration as shown below.




Ensure that you choose the "Chunked Read" operation and define a chunk size - This will be the number of records in the file that will be read in each iteration. For instance., if you have 12 records with a chunk size of 3, the adapter would read the file in 4 chunks.

















Step2: Implement the BPEL section
In order to process the file in chunks, the BPEL process invoke that triggers the File Adapter must be placed within a while loop. During each iteration, the file adapter uses the property header values to determine where to start reading.

At a minimum, the following are the JCA adapter properties that must be set;

jca.file.FileName : Send/Receive file name. This property overrides the adapter configuration. Very handy property to set / get dynamic file names
jca.file.Directory : Send/Receive directory location. This property overrides the adapter configuration
jca.file.LineNumber : Set/Get line number from which the file adapter must start processing the native file
jca.file.ColumnNumber : Set/Get column number from which the file adapter must start processing the native file
jca.file.IsEOF : File adapter returns this property to indicate whether end-of-file has been reached or not
Apart from the above, there are 3 other properties that helps with error management & exception handling.
jca.file.IsMessageRejected : Returned by the file adapter if a message is rejected (non-conformance to the schema/not well formed)
jca.file.RejectionReason : Returned by the file adapter in conjunction with the above property. Reason for the message rejection
jca.file.NoDataFound : Returned by the file adapter if no data is found to be read

In the BPEL process "Invoke" activity, only jca.file.FileName and jca.file.Directory properies are available to choose from the properties tab. We will have to configure the other properties manually.

First, let's create a bunch of BPEL variables to hold these properties. For simplicity, just create all variables with a simple XSD string type.


Variables created:
    <variable name="lineNumber" type="xsd:string"/>
    <variable name="columnNumber" type="xsd:string"/>
    <variable name="isEOF" type="xsd:string"/>
    <variable name="returnLineNumber" type="xsd:string"/>
    <variable name="returnColumnNumber" type="xsd:string"/>
    <variable name="returnIsEOF" type="xsd:string"/>
    <variable name="returnIsMessageRejected" type="xsd:string"/>
    <variable name="returnRejectionReason" type="xsd:string"/>
    <variable name="returnNoDataFound" type="xsd:string"/>

Drag & drop an assign activity before the while loop to initialize the variables for the first time the file is read (first chunk) - since we know the first chunk of data will start at line 1 and column 1.

lineNumber -> 1
columnNumber -> 1
isEOF -> 'false'





Invoke properties:
<invoke name="Invoke_fileReference" partnerLink="fileReference" portType="ns1:ChunkedRead_ptt"
                operation="ChunkedRead" inputVariable="Invoke_fileReference_ChunkedRead_InputVariable"
                outputVariable="Invoke_fileReference_ChunkedRead_OutputVariable" bpelx:invokeAsDetail="no">
          <bpelx:toProperties>
            <bpelx:toProperty name="jca.file.LineNumber" variable="lineNumber"/>
            <bpelx:toProperty name="jca.file.ColumnNumber" variable="columnNumber"/>
          </bpelx:toProperties>
          <bpelx:fromProperties>
            <bpelx:fromProperty name="jca.file.LineNumber" variable="returnLineNumber"/>
            <bpelx:fromProperty name="jca.file.ColumnNumber" variable="returnColumnNumber"/>
            <bpelx:fromProperty name="jca.file.IsEOF" variable="returnIsEOF"/>
            <bpelx:fromProperty name="jca.file.IsMessageRejected" variable="returnIsMessageRejected"/>
            <bpelx:fromProperty name="jca.file.RejectionReason" variable="returnRejectionReason"/>
            <bpelx:fromProperty name="jca.file.NoDataFound" variable="returnNoDataFound"/>
            <bpelx:fromProperty name="jca.file.FileName" variable="csvfile"/>
          </bpelx:fromProperties>
        </invoke>

Within the while loop, drag & drop another assign activity to re-assign file adapter properties.
returnIsEOF -> isEOF
returnLineNumber -> lineNumber
returnColumnNumber -> columnNumber


Now deploy it to EM console and test 

The file is polled in chunks 4 time. as the number of lines in the file is 12 and chunk size is 3.

Bug or cons:
If we implement the chunk read, we will find that the file does not get deleted post reading the file.
It is because the file can be deleted only outside the loop of chunk read.

File adapter provides feature to delete the file from a location.
Provided we are getting the file name and file location, we can easily create an adapter to delete the file post chunk reading
Create a simple file adapter with sync read option

















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...