Tuesday, October 27, 2020

12c SOA Weblogic console - Database - shared memory realm does not exist IBM AIX RISC System/6000 Error: 2: No such file or directory error

While one of the SOA external DB was upgrading to 19c, I have stumbled with this following error during the datasourse connection testing.

Test of WorkboothDB on server osb_server1 failed, reason:

Error Connection test failed with the following exception: weblogic.common.resourcepool.ResourceDeadException: 0:weblogic.common.ResourceException: ORA-01034: ORACLE not available ORA-27101: shared memory realm does not exist IBM AIX RISC System/6000 Error: 2: No such file or directory

Solution:

This is because the Database instance name got changed. I have used the correct instance name and it got resolved.


Tuesday, October 20, 2020

OIC - Connectivity Agent part 1

 This includes:

  • Connectivity Agent
  • Agent types
  • Connectivity agent architecture
  • Agent in HA Availability
  • Agent Group
  • Connectivity agent constraints
Connectivity Agent:
  • A connectivity agent or on  premise agent is a light weight component which solve the problem of cloud to on premise integration.
  • The agent is required to exchange messages with on premises application such as database, Oracle E-Business suite, systems, Applications and SAP products, Ariba etc. 
  • This CA can be installed behind the firewall to access on-premises applications.
Agent Types:
  • Connectivity agent
    • This is the intermediate gateway which provides a connection between SaaS and on-premises application or vice-versa.
  • Execution agent
    • This is self-managed instance of OIC help to connect applications within the organizations that enable secure integration between these systems residing on premise.
Connectivity Agent Architecture:
  • The agent work as a bridge between OIC and On premises applications and without that communication is not possible.
  • The OIC does not send any request to CA but CA does this job. Agent sends his heartbeat signals to Oracle Integration regularly to tell that I am live to serve your requests. In addition, to that agent regularly poll for design and run time work on which agent need to act upon.
  • Design time work includes set of activities like Test connection, activation or deactivation of integrations.
  • Same ways there are run time activities on which agent need to act upon. For any communication between integration cloud and on-premises systems such as Databases, EBS etc.

Agent Group:

  • An agent group is a unique identifier which comprises multiple connectivity agents.
  • You must create a agent group in OIC before you can run the connectivity agent installer.
  • For a single oracle integration instance, you can create up to 5 agent groups. If the limit exceeds, you will get error like "Max limit reached. Maximum 5 Connectivity agents can be added."

Connectivity Agent in HA :

To tackle the high traffic on a single connectivity agent, you can install Connectivity Agent in High Availability mode. you can associate max two agents with a single agent group and both the agents should run on different hosts. The HA mode ensures the transactions will continue if any of the agents goes down or any hosts becomes unavailable.

Connectivity agent constraints:

  • 10 MB payload limit
    • The OIC agent can handle payload in size which is less than 10 MB in a single transaction.
  • 240 sec or 4 mins Timeout
    • Every transaction sent out to the on-premises application via agent must be completed within 240 seconds.



Monday, October 19, 2020

OIC - create PGP key to use in FTP connection

Go to pgpkeygen and fill up few details like your name, email id and choose algorithm as RSA , key size as 4096 bits(more secure). expires and passphrase and click generate keys.

Now download the keys.
Downloaded private and public PGP key files:


Thursday, October 15, 2020

12c SOA Synchronous BPEL process with a wait activity fails with a timeout

The Wait activity works well with an asynchronous BPEL process but not with a synchronous BPEL process where a transaction is required. The Wait activity involves a dehydration. Dehydration will persist the process and continue the process in a new thread. When the BPEL process is transaction required, the persist will not be complete until the BPEL process completes and transaction commits.

Synchronous BPEL process with a wait activity fails with a timeout

One of the solutions is possible:

Remove the following line from the synchronous BPEL process component:

required

OR

Change bpel.config.transaction to “requiredNew”

requiredNew

Monday, September 14, 2020

Bash scripting and shell programming linux part 4

Data manipulations and text transformations with SED:

  • SED=Stream Editor
  • A stream is data that travels from one process to another through pipe, one file to another as redirect or one device to another.
  • Sed performs text transformation on streams.
    • Examples:
      • substitute some text with other text
      • removes lines
      • Append text after given lines
      • Insert text before certain lines

 type -a sed

sed is /usr/bin/sed

sed is /bin/sed

Syntax:
sed 's/search-pattern/replacement-pattern/flags' file_name

Example:
echo 'I love my wife.' > love.txt
cat love.txt
I love my wife.
sed 's/my wife/sed/' love.txt
I love sed.

Scripting is case sensitive so we can use use "i" flag to make it  case insensitive with sed
sed 's/MY WIFE/sed/I' love.txt
or
sed 's/MY WIFE/sed/i' love.txt

to append a line to a existing a file:
echo 'this is line 2.' >> love.txt
cat love.txt
I love my wife.
this is line 2.

Change my wife with sed
cat love.txt
I love my wife.
this is line 2.
I love my wife with all of my heart.
sed 's/my wife/sed/' love.txt
I love sed.
this is line 2.
I love sed with all of my heart.


sed 's/my wife/sed/' love.txt
I love sed.
this is line 2.
I love sed with all of my heart.
I love sed and my wife loves me too

globally change all the words "my wife" with sed:
sed 's/my wife/sed/g' love.txt
I love sed.
this is line 2.
I love sed with all of my heart.
I love sed and sed loves me too

change the 2nd word "my wife" in a line
sed 's/my wife/sed/2' love.txt
I love my wife.
this is line 2.
I love my wife with all of my heart.
I love my wife and sed loves me too

Save in a file
sed 's/my wife/sed/2' love.txt >ex.txt
cat ex.txt
I love my wife.
this is line 2.
I love my wife with all of my heart.
I love my wife and sed loves me too

delete a line starting with "this"
sed '/this/d' love.txt
I love my wife.
I love my wife with all of my heart.
I love my wife and my wife loves me too

using escape characters:
echo '/home/test' | sed 's/\/home\/test/\/home\/var\/test/'
/home/var/test

echo '/home/test' | sed 's:\/home\/test:\/home\/var\/test:'
/home/var/test

To delete a line based on a word/char starting with the line.
echo '#User to run service as.' > config
echo 'User apache' >> config
echo '#Group to run service as ' >> config
echo 'Group apache' >>config
 cat config
#User to run service as.
User apache
#Group to run service as
Group apache
sed '/^#/d' config
User apache
Group apache

awk:

  • Awk is a scripting language used for manipulating data and generating reports.The awk command programming language requires no compiling, and allows the user to use variables, numeric functions, string functions, and logical operators.
  • Awk is a utility that enables a programmer to write tiny but effective programs in the form of statements that define text patterns that are to be searched for in each line of a document and the action that is to be taken when a match is found within a line. Awk is mostly used for pattern scanning and processing. It searches one or more files to see if they contain lines that matches with the specified patterns and then performs the associated actions.
  • Awk is abbreviated from the names of the developers – Aho, Weinberger, and Kernighan.
Syntax:

awk options 'selection _criteria {action }' input-file > output-file

Options:
-f program-file : Reads the AWK program source from the file 
                  program-file, instead of from the 
                  first command line argument.
-F fs : Use fs for the input field separator


To print every lines of a file:
awk '{print}' config
#User to run service as.
User apache
#Group to run service as
Group apache

Print the lines which matches with the given pattern.
awk '/User/ {print}' config
#User to run service as.
User apache

Splitting a Line Into Fields :
For each record i.e line, the awk command splits the record delimited by whitespace character by default and stores it in the $n variables. If the line has 4 words, it will be stored in $1, $2, $3 and $4 respectively. Also, $0 represents the whole line.

awk '{print $1, $3}' config
#User run
User
#Group run
Group

Built In Variables In Awk:
Awk’s built-in variables include the field variables—$1, $2, $3, and so on ($0 is the entire line) — that break a line of text into individual words or pieces called fields.

NR: NR command keeps a current count of the number of input records. Remember that records are usually lines. Awk command performs the pattern/action statements once for each record in a file.

NF: NF command keeps a count of the number of fields within the current input record.

FS: FS command contains the field separator character which is used to divide fields on the input line. The default is “white space”, meaning space and tab characters. FS can be reassigned to another character (typically in BEGIN) to change the field separator.

RS: RS command stores the current record separator character. Since, by default, an input line is the input record, the default record separator character is a newline.

OFS: OFS command stores the output field separator, which separates the fields when Awk prints them. The default is a blank space. Whenever print has several parameters separated with commas, it will print the value of OFS in between each parameter.

ORS: ORS command stores the output record separator, which separates the output lines when Awk prints them. The default is a newline character. print automatically outputs the contents of ORS at the end of whatever it is given to print.


awk '{print NR,$1}' config
1 #User
2 User
3 #Group
4 Group

 awk '{print NR,$0}' config
1 #User to run service as.
2 User apache
3 #Group to run service as
4 Group apache

awk '{print NR,NF,$0}' config
1 5 #User to run service as.
2 2 User apache
3 5 #Group to run service as
4 2 Group apache

To print the first item along with the row number(NR) separated with ” – “
awk '{print NR "-" $1}' config
1-#User
2-User
3-#Group
4-Group

To print any non empty line if present
awk 'NF > 0' config
#User to run service as.
User apache
#Group to run service as
Group apache

 To find the length of the longest line present in the file:
 awk '{ if (length($0) > max) max = length($0) } END { print max }' config

25

To count the lines in a file:
awk 'END {print NR} ' config
4

Printing lines with more than 10 characters:
 awk 'length($0) > 10' config
#User to run service as.
User apache
#Group to run service as
Group apache

To print the squares of first numbers from 1 to n say 6:
awk 'BEGIN { for(i=1;i<=6;i++) print "square of", i, "is",i*i; }'
square of 1 is 1
square of 2 is 4
square of 3 is 9
square of 4 is 16
square of 5 is 25
square of 6 is 36




Friday, September 11, 2020

Curl command - Test a rest API

About curl command:

  • curl is a command line tool to transfer data to or from a server, using any of the supported protocols (HTTP, FTP, IMAP, POP3, SCP, SFTP, SMTP, TFTP, TELNET, LDAP or FILE).
  •  curl is powered by Libcurl. This tool is preferred for automation, since it is designed to work without user interaction. curl can transfer multiple file at once

syntax:

curl [options] [URL...]

Here are the options that we’ll use when making requests:

-X, --request - The HTTP method to be used.

-i, --include - Include the response headers.

-d, --data - The data to be sent.

-H, --header - Additional header to be sent.


Verbose:

When we are testing, it’s a good idea to set the verbose mode on:

curl -v http://www.example.com/

As a result, the commands would provide helpful information such as the resolved IP address, the port we are trying to connect to and the headers.

Example:

curl  -v -d '{"Customer": {"ID": "ID10","Name": "Name11","Address": "Address12"}}' -H 'Content-Type: application/json' http://localhost:8001/soa-infra/resources/POC/LoopInBPELProject/RestService/abc

* Connected to host  (host ip) port 8001

> POST /soa-infra/resources/POC/LoopInBPELProject/RestService/abc HTTP/1.1

User-Agent: curl/7.9.3 (powerpc-ibm-aix5.3.0.0) libcurl 7.9.3 (OpenSSL 0.9.8y) (ipv6 enabled)

Host: localhost:8001

Pragma: no-cache

Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*

Content-Type: application/json

Content-Length: 68

{"Customer": {"ID": "ID10","Name": "Name11","Address": "Address12"}}

<CustomersRes xmlns="http://www.cust.abc">

   <Outcome>ID10</Outcome>

</CustomersRes>

* Connection #0 left intact

* Closing connection #0

Output:

By default, curl outputs the response body to standard output. Optionally, we can provide the output option to save to a file:

curl -o out.json http://www.example.com/index.html

This is especially helpful when the response size is large.

Example:

curl  -o response.xml -d '{"Customer": {"ID": "ID10","Name": "Name11","Address": "Address12"}}' -H 'Content-Type: application/json' http://host:8001/soa-infra/resources/POC/LoopInBPELProject/RestService/abc
-rw-r--r--    1 oracle   dba              86 Sep 11 06:20 response.xml
cat response.xml
<CustomersRes xmlns="http://www.cust.abc">
   <Outcome>ID10</Outcome>
</CustomersRes>

POST:
We use this method to send data to a receiving service. And for that, we use the data option.

curl -d 'id=9&name=sri' http://localhost:8082/testurl
or, pass a file containing the request body to the data option like this:

curl -d @request.json -H "Content-Type: application/json" 
  http://localhost:8082/testurl

Example:
curl   -d @request.json -H 'Content-Type: application/json' http://host:8001/soa-infra/resources/POC/LoopInBPELProject/RestService/abc
<CustomersRes xmlns="http://www.cust.abc">
   <Outcome>ID10</Outcome>
</CustomersRes>

GET:
This is the default method when making HTTP calls with curl. In fact, the examples previously shown were plain GET calls.
While running a local instance of a service at port 8082, we'd use something like this command to make a GET call:
curl -v http://localhost:8082/testurl

Authentication:
If the API endpoint requires authentication, you’ll need to obtain an access key. Otherwise, the API server will respond with the “Access Forbidden” or “Unauthorized” response message.

The process of obtaining an access key depends on the API you’re using. Once you have your access token you can send it in the header:

curl -X GET -H "Authorization: Bearer {ACCESS_TOKEN}" "https://api.server.io/posts"

-u  option: curl also provides options to download files from user authenticated FTP servers.
Syntax:

curl -u {username}:{password} [FTP_URL]


how to store the rest response to a variable using shell script:
cat > curl.sh
#!/usr/bin/bash
var=$(curl -d '{"Customer": {"ID": "ID10","Name": "Name11","Address": "Address12"}}' -H 'Content-Type: application/json' http://uadcc-elmweb01:8001/soa-infra/resources/POC/LoopInBPELProject/RestService/abc)
echo $var

chmod 777 curl.sh
./curl.sh
  % Total    % Received % Xferd  Average Speed          Time             Curr.
                                 Dload  Upload Total    Current  Left    Speed
100    86  100    86    0     0   1954      0  0:00:00  0:00:00  0:00:00 86000
<CustomersRes xmlns="http://www.cust.abc"> <Outcome>ID10</Outcome> </CustomersRes>

12c SOA - How to call a shell script from BPEL using java embedding

 Implementation steps:

Step 1: Create a SOA project with empty composite.

Step 2: Create an XSD.

<?xml version="1.0" encoding="windows-1252" ?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.example.org"

            targetNamespace="http://www.example.org" elementFormDefault="qualified">

  <xsd:element name="Input">

    <xsd:complexType>

      <xsd:sequence>

        <xsd:element name="num1" type="xsd:string"/>

        <xsd:element name="num2" type="xsd:string"/>

      </xsd:sequence>

    </xsd:complexType>

  </xsd:element>

    <xsd:element name="Output">

    <xsd:complexType>

      <xsd:sequence>

        <xsd:element name="result" type="xsd:string"/>

      </xsd:sequence>

    </xsd:complexType>

  </xsd:element>

</xsd:schema>


Step 3: Create a Synchronous BPEL service using that schema exposing as a web service.

Step 4: Create a Shell script file and saved in UNIX directory.

Test.sh:

#!/usr/bin/bash

num1=$1

num2=$2

function add(){

sum=`expr $num1 + $num2`

echo "$sum"

return $sum

}

add $num1 $num2


Step 5 : Create a Java class(Right click on project⇾ New Galary⇾ Class(Java))

Test.java:

package invokeshellscriptproject;

import java.io.*;

public class Test {

          public String ShellScript(int i, int j) throws IOException

          {

               String Var=null;

          try{

                Process P;

                System.out.println(i);

                System.out.println(j);

              String strParam = "bash /soashare/shellscript/test.sh "

                                                     +i+" "+j+" ";

                                     P = Runtime.getRuntime().exec(strParam);

             System.out.println("here " + strParam);

             BufferedReader br = new BufferedReader(new InputStreamReader(P.getInputStream()));

            String line=null;

             while ( (line = br.readLine()) != null){

                        System.out.println("Output" + ">" + line);

                  Var=line;

                        }

                System.out.println(line);

                System.out.println("Output of Var:-"  +Var);

            int wait = P.waitFor();

            System.out.println("exit code: "+wait);

            }

            catch (InterruptedException ie)

            {

              System.out.println("exception caught");

            }

            catch (Throwable t)

                  {

                    t.printStackTrace();

                  }

               return Var;

           }

}


Step 6: Create a string variable Var1.

Step 7:  Drag and drop a Java embedding activity in the BPEL.

Java_Embedding2:

Test pocob = new Test();               

try{         

addAuditTrailEntry("Started From This Place");        

String i = ((oracle.xml.parser.v2.XMLElement)getVariableData("inputVariable","payload","/ns1:Input/ns1:num1")).getFirstChild().getNodeValue();    

int k = Integer.parseInt(i);        

addAuditTrailEntry("k Variable " +k);        

String j = ((oracle.xml.parser.v2.XMLElement)getVariableData("inputVariable","payload","/ns1:Input/ns1:num2")).getFirstChild().getNodeValue();           

int n = Integer.parseInt(j);        

addAuditTrailEntry("n Variable " +n);        

addAuditTrailEntry("Before Variable");        

String greetings = pocob.ShellScript(k,n);       

addAuditTrailEntry("After Variable");        

addAuditTrailEntry("Value:- " +greetings);        

setVariableData("Var1",greetings);     //Var1 is a variable created in BPEL process to contain result     

addAuditTrailEntry("After Assignment");        

}        catch(Exception io){                                                                          

      addAuditTrailEntry("Exception occured:"+io.getMessage());                                                          

      javax.xml.namespace.QName qName=new javax.xml.namespace.QName("http://schemas.oracle.com/bpel/extension","remoteFault");                                                                               

      com.oracle.bpel.client.BPELFault bpelFault=new com.oracle.bpel.client.BPELFault(qName);               

      throw bpelFault;                                 

    }       

finally{        

pocob=null;   

}


Step 8 : Import the java class in the BPEL. location used as packageName.ClassName

<import location="invokeshellscriptproject.Test" importType="http://schemas.oracle.com/bpel/extension/java"/>

Step 9 : Assign Var1 to result variable.

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