Sunday, 21 January 2018

For each activity

For Each Activity

Introduction
    
     In BPEL 2.0 FlowN activity is been replaced with the foreach activity.  This activity from the name work on a group of similar objects and process them each. Processing of the objects depends on choice made by the developer, it can either sequentially processed or it can also processed in parallel. Parallel some time considered as parallel and multi threaded execution in the JVM. While its not true, Oracle SOA is not a multi-threaded environment. Hence parallel just mean if first flow is waiting for answer it start executing the second flow but in a single thread.  Hence anyway it can never be actual parallel in true sense if we think in java terms. But still feature is useful let say we are executing a service to find information about a car 6 times and service takes 2 second to answer, hence instead of taking entire flow 12 second it may take 3-4 second only as during the wait other flows will be executed. 



Major Parts


1. Activity Name
Simple name of the activity, does not play any major role in the processing of the component. 

2.Counter Name
This is the self increased counter value,which keep on increasing once we do it for  

3.Start Value
This is the value of the counter when the activity is initiated, this is decided on run-time. You can have a static value here too.

4.End Value
 This is the final value of the counter, where loop terminate. 

5.Completion condition
Not mandatory but it will provide the  condition which will be considered as a completion of the activity. 

Parallel flow will give an indication to execution engine, if activity has to run in parallel or sequential.








Example :

Link to download.

Example we are discussing here is an simple example where we are giving a bulk data to a car system to execute and give us information on various aspects.  This example is kind of prefect case where 


Please download the example from the link, we are using hr database for the Database adapter, hence its advisable to configure the database before running the example.  Project also have file TableCreationScript.sql, this file will provide you table been used in the example and data inserted.


Design :-  This example take input of the car numbers in the array and process everything in one go go using a froeach statement. Foreach activity process entire array one by one and then put the result in other array.  Payload is provided in the folder with the project.





Working: Once you provide the payload given then it will take the payload and assign each of the result one by one and then process the entire set one by one.

   1. Provide input to the process, and select the payload from the folder given,



 2. Once testing is done click the Launch the Flow Trace.


3. See and analyse the flow happen post the foreach. It will give a view like its running in parallel. its not acutely parallel but its the best use of the resources. 




 Here Oracle SOA provide an alternative also where you can control the execution to sequential, this is to tell process engine not to start another iteration if one is not complete or in waiting state at any place.

Hence if your operation are fine to run kind of parallel,  This is the activity for you and check parallel execution if not then just un-check parallel and it will start behaving your pet sheep, one going after another.



 
Exercise : -
1. Make output variable of the db adapter global and check how it start behaving, i am sure you will get to know some idea behind it.








No comments:

Post a Comment