Saturday, May 9, 2020

Database - create package and procedure

Here showing you an insert events package and procedure creation.

Package creation:
create or replace PACKAGE "PCK_PROVISIONING"
AS
  /* enter package declarations (types, exceptions, methods etc) here */
PROCEDURE INSERT_EVENT_IN_PROGRESS(
    EMP_NUMBER     VARCHAR2,
    EMP_COUNTRY    VARCHAR2,
    BPEL_INST_ID   VARCHAR2,
    EMP_LAST_NAME  VARCHAR2,
    EMP_FIRST_NAME VARCHAR2,
    EV_ID OUT NUMBER );
END pck_provisioning;

Package body:
create or replace PACKAGE BODY "PCK_PROVISIONING"
AS
PROCEDURE INSERT_EVENT_IN_PROGRESS
  (
    EMP_NUMBER     VARCHAR2,
    EMP_COUNTRY    VARCHAR2,
    BPEL_INST_ID   VARCHAR2,
    EMP_LAST_NAME  VARCHAR2,
    EMP_FIRST_NAME VARCHAR2,
    EV_ID OUT NUMBER
  )
AS
BEGIN
/* calling the Insert_Event() procedure*/
  INSERT_EVENT
  (
    EV_TYPE => 'T', EMP_NUMBER => EMP_NUMBER , EMP_COUNTRY => EMP_COUNTRY, EV_STATUS => 2,            -- 2.- In Progress
    BPEL_INST_ID => BPEL_INST_ID, LAST_NAME => EMP_LAST_NAME, FIRST_NAME => EMP_FIRST_NAME, STS => 1, -- 1.- Active
    EV_ID => EV_ID
  );
END INSERT_EVENT_IN_PROGRESS;
/* called the Insert_Event() procedure body with Table.field%type */
PROCEDURE INSERT_EVENT(
    EV_TYPE EMPLOYEE_EVENT.EVENT_TYPE%type, 
    EMP_NUMBER EMPLOYEE_EVENT.EMPLOYEE_NUMBER%type,
    EMP_COUNTRY VARCHAR2,
    EV_STATUS EMPLOYEE_EVENT.EVENT_STATUS%type,
    STS EMPLOYEE_EVENT.STATUS%type,
    BPEL_INST_ID EMPLOYEE_EVENT.BPEL_INSTANCE_ID%type,
    LAST_NAME EMPLOYEE_EVENT.EMPLOYEE_LAST_NAME%type,
    FIRST_NAME EMPLOYEE_EVENT.EMPLOYEE_FIRST_NAME%type,
    EV_ID OUT EMPLOYEE_EVENT.EMPLOYEE_EVENT_ID%type )
AS
BEGIN
--Calling a sequence to get the event id.
  SELECT EMPLOYEE_EVENT_SEQ.NEXTVAL INTO EV_ID FROM DUAL;
--Inserting data to Employee_event table
  INSERT INTO EMPLOYEE_EVENT(
      EVENT_DATETIME,
      EVENT_TYPE,
      EMPLOYEE_NUMBER,
      EMPLOYEE_COUNTRY,
      EVENT_STATUS,
      STATUS,
      BPEL_INSTANCE_ID,
      EMPLOYEE_FIRST_NAME,
      EMPLOYEE_LAST_NAME,
      EMPLOYEE_EVENT_ID
    )
    VALUES(
      SYSDATE,
      EV_TYPE,
      EMP_NUMBER,
      EMP_COUNTRY,
      EV_STATUS,
      STS,
      BPEL_INST_ID,
      LAST_NAME,
      FIRST_NAME,
      EV_ID
    );
END INSERT_EVENT;

END pck_provisioning;

Unix or AIX box - remove zero size files from a directory


In our AIX box, we observed, when the files system got 100% utilized, it used to create files with zero size for all the incoming files via file adapter. so need to clear all the zero size files at a fly.

This works for plain BSD so it should be universally compatible with all flavors.

Command:
find . -size 0 |  xargs rm

12c SOA - Weblogic - delete JMS Queue messages from persistent store level

Sometimes we are facing a situation where a gigantic amount of messages are stored in the JMS queue but not processing at all and we are also not able to remove them from the queue itself. There is one alternate option to clear the messages from the persistent store level itself.

Solution steps:

Step1: Check the persistent store path, go to the path and delete SOA_JMSFILESTORE.DAT file
cd app/Oracle/Middleware/Oracle_Home/user_projects/domains/soa-osbdomain/servers/soa_server1/data/store/default
 ll
total 4112
-rw-r-----    1 oracle   dba         1052672 Apr 09 21:21 SOA_JMSFILESTORE1000000.DAT

rm SOA_JMSFILESTORE1000000.DAT

Step2: Restart the affected the manage servers. Like in this case, I have restarted the SOA1 Manage Server.



Wednesday, March 18, 2020

https service call - java.security.cert.CertPathValidatorException: Certificate chaining error

While we try to call a https external service from SOA composites, we  face following kind of certificate error:
Error:
oracle.fabric.common.FabricInvocationException: Unable to invoke endpoint URI "https://external-service/soap/V2.ASMX" successfully due to: javax.xml.soap.SOAPException: javax.xml.soap.SOAPException: Message send failed: com.ibm.jsse2.util.h: PKIX path building failed: java.security.cert.CertPathBuilderException: PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause is:
java.security.cert.CertPathValidatorException: The certificate issued by CN=DigiCert High Assurance EV Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US is not trusted; internal cause is:
java.security.cert.CertPathValidatorException: Certificate chaining error

Solution:
We need to import the certificate of this service to weblogic server lib location and then restart the impacted servers.

check steps here 12c-soa-weblogic-certificate-import.

12c - keytool - Delete certificate from Java Keystore using alias name

Solution
We need alias name to delete a specific certificate from java keystore.

Please use the following command:
Syntax:
keytool -delete
 -alias keyAlias
 -keystore keystore-name
 -storepass password

Example:
/usr/java8_64/bin/keytool -delete -alias cavent  -keystore SOAKeysTrust.jks -storepass CUSTOMPASS

here /usr/java8_64/bin/ is the java bin path added.


12c SOA -UMS Adapter send outbound email

To send an outbound email, we have to configure following 2 steps:
  • Email driver setup.
  • UMS adapter configurations.
Here I will show you the UMS adapter configuration and send outbound emails without attachment.

Implementation:
Create a SOA project.


 Create a XSD:


 <?xml version='1.0' encoding='windows-1252'?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.email.soa" targetNamespace="http://www.email.soa" elementFormDefault="qualified">
   <xsd:element name="EmailInput" type="EmailType"/>
   <xsd:complexType name="EmailType">
      <xsd:sequence>
         <xsd:element name="Email">
            <xsd:complexType>
               <xsd:sequence>
                  <xsd:element name="EmailContent" type="xsd:string"/>
<xsd:element name="EmailSubject" type="xsd:string"/>
                  <xsd:element name="From" type="xsd:string"/>
                  <xsd:element name="To" type="xsd:string"/>
                  <xsd:element name="EmailAttachmentString" type="xsd:string"/>
               </xsd:sequence>
            </xsd:complexType>
         </xsd:element>
      </xsd:sequence>
   </xsd:complexType>
</xsd:schema>

UMS Adapter Configuration:






 Create a BPEL Process



 Take a invoke and call the UMS partnerlink

 Assign the email content.

 In the invoke properties, we will assign the jca to from etc. properties.
 Deploy and test


Tuesday, March 17, 2020

12c SOA - JMS Message rollback

Introduction:
When a JMS adapter consumes a message from a Weblogic JMS queue/topic, the message is removed from it. Imagine a situation where a SOA process consumes a messages from a JMS through JMS adapter but the process fails before its execution is complete. This will lead to message loss as the message was already removed from the JMS and cannot be recovered even if the SOA transcation is rolled back. JMS adapter in Oracle SOA behaves as an asynchronous service (one-way service). This will cause the BPEL engine to split the execution into two parts.
  • First, and always inside the caller transaction, the insert into the dlv_message table, and
  • secondly the transaction & new thread that executes the workitems, and creates a new instance.
Hence the JMS adapter and the SOA components (BPEL and Mediators) work in different transactions. The message consumed by JMS adapter from JMS is stored in dlv_message table and the transaction is committed. The BPEL worker threads then picks up the message from the dlv_message and executes in a different transaction.In case of any error in the BPEL process the message from the JMS is lost and cannot be retried.



 Following way we can rollback the JMS messages without losing them in case of any error in the BPEL process.

Solution: Using Synchronous process
we modify the wsdl of the JMS adapter.
The wsdl of the JMS adapter that is generated is asynchronous(one-way) we change it to synchronous.

Add an empty element in the schema of the wsdl.
<element name="empty"/>
Create a new message type.
<wsdl:message name="Ignore_Message_msg">
<wsdl:part name="ignore" element="empty"/>
</wsdl:message>
Add an output to the operation in the wsdl with the newly created message.
<wsdl:output message="tns:Ignore_Message_msg"/>
This will make the wsdl as synchronous.

In the BPEL, add a reply activity and connect it to the JMS adapter, when asked for variable just mention the message type you have just created in the wsdl.
Note: In this approach we need not to add following properties in the Composite.xml file.
  • bpel.config.transaction
  • bpel.config.oneWayDeliveryPolicy

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