Monday, 9 September 2013

WHAT IS CORRELATION ID,WHY WE USE IT,SAMPLE BPEL PROGRAM

CORRELATION ID :

When an asynchronous service is initiated with the invoke activity, a correlation ID unique to the client request is also sent (using WS Addressing). Because multiple processes may be waiting for service callbacks, Oracle BPEL Server must know which BPEL process instance is waiting for a callback message from the loan application approver Web service. The correlation ID enables Oracle BPEL Server to correlate the response with the appropriate requesting instance

Suppose we have  asynchronous calls: like call 1 call2,call 3 ,call 4 ,call 5 and bpel is waiting for response.There is chance that call3 response call came before call2,or call5 resonse came before call 1.In order to control and map source and response messages correlation id is used.

Here we have few properties whose meaning are explained below :

Initiate = yes  --->  this means that we assign the value to correlation variable.

Initiate=no ----->    this means, we want to validate the value against, value stored in correlation variable.

Pattern = in ----> initiated with something that is coming into the bpel

Pattern= out -----> initiated with something that is going out of bpel.

Pattern= in/out -----> initiated with something that is going in and out of bpel.


SAMPLE BPEL SERVICE :

STEP 1 : Create a simple asynchronous Bpel service as shown below :




 STEP 2 : Map the assign activity of source input with output variable and concat some values as shown below :



STEP 3 :Next create another asynchronous Bpel service which calls bpl created before via wsdl as shown below :





 STEP 4 : In this step we need to create the correlation set .For this go to top of Bpel service and click on icon "marked in green " o right side   as shown below :



STEP 5 : A new window opens,,click + sign on top,Give name like :Correlation_set1->Click OK and below page will come.





STEP 6 :Now for this set create new property ,give some logical name on clicking + sign and below page will come :



STEP 7 : Now keep your mouse on property value,click on  green + sign.

STEP 8 : Just think and understand which all variables we need to compare so add them accordingly one by one.and click OK.




STEP 9 : Once all added the property it will look like this :




STEP 10 :Click OK.Now correlation set s ready.Now this property we need to add in receive activity as shown below ,double click on receive activity at top go to correlation tab and provide below settings:






See carefully since we are setting values so initiate = yes


STEP 11 :In next receive after invoke we set this field :





See carefully since we are comparing the set values so initiate =no.


STEP 12:Our complete bpel looks like below figure.Just simple asyncronous bpel with call to another bpel via wsdl service and receiving reply via service through correlation call.




STEP 13 : Now we are ready to compile test our code.Its negative test so correlation id  will stop from progressing this bpel as record values are different.


STEP 14 : Below is the negative test screenshot:




Happy Programing..............

Sunday, 8 September 2013

SIMPLE JAVA EMBEDDING IN BPEL SERVICES

This tutorial explains how to embed java program in Bpel service.

STEP 1 :  Go to jdeveloper -> Create a new project

STEP 2 : Drag a Java embedding service into Bpel service between receive and reply activity
                as shown below.Also  drag and drop two assign activities as shown below.


     

STEP 3 : Double click on java embedding activity and write lines of code you wish.Below are lines I wrote to concatenate two strings.

String read1=(String)getVariableData("Variable1_input");      
String read2=(String)getVariableData("Variable1_input1");      

      
try     
{     
      
System.out.println("Hello");   
String read3 = read1.concat(read2); 
setVariableData("Variable1_output",read3);  

     
}     
     
catch (Exception e)       
     
{     
     
System.out.println("Error"); 
 
}


Please note the above code is just like we write in java but bpel will not throw any error on failed compilation.Only error " scac 50012" will come.So unless you are good in compiling code its tough to write logical programs.


STEP 5 : Double click on assign activity to map outpariable of java with output variable of bpel variable.

STEP 6: Compile Deploy and test your services.


Happy Programming.............