The Oracle SOA 12c is bringing us a lot of new nice features and one that has really caught my attention is the SubProcess feature.
The SubProcess eliminates the need for writing the same code more than once on the same process or the need to pass the bureaucratic process of creating a new process bpel like the wsdl, BPEL versions (It works with BPEL 2.0 only!), sync/async, etc.
Let’s start our example by creating a new BPEL Process in a SOA Project on JDeveloper 12c:
You will notice that unlike 11g the new default specification for BPEL processes is 2.0, leave it as it is, the new SubProcess feature will work on 2.0 specification only!
Back on the composite.xml, create a new subprocess:
When you open the SubProcess, you will see an empty sequence with no receive or invoke actions. You will be able to call this sequence from any part of your BPEL process, even inside a fault handler.
So for an example, my subprocess will read a string variable, concatenate that string value with “Hello ” and assign that valu to another variable. To do that I will create two variables on my process:
Important: you can read/write on multiple variables on the subprocess and they can all be read on the calling main process as we will see later in the post.
We will create an assign activity on the subprocess for our return:
And we assign our hello to the VariableWrite variable…
Our subprocess is set, let us go back to our main process:
On Components palette, lets a drag subprocess component into our sequence:
By double -clicking it you can choose your sub-process and interact with the variables:
The Copy By Value Option
As you can see by default the editor sets the variables in the process as “Copy By Value”, that means the main process will fill up the variables with the values you assign to it but any alterations made to those values in the Sub-Process will have NO effect on the variables from the main process.
If you need the value altered by the subprocess to be effective on the variables at your main process you will need to UNCHECK that box, I will do this to my “VariableWrite” as you can see below:
Values to variables can be either a reference to a variable on a main process or an expression, however if you uncheck Copy By Value it will only accepts reference. This makes sense because you are expected to receive values generated by the subprocess on those.
So for our test I am sending on the VariableRead the string I get in the process input variable and for the Variable Write I will create a string variable on the main process as you can see below:
To see the value changed at the of the process I will create an assign to the outputvariable from the returned variable:
Ok, time to test our creation, after deployment, we will have this on em: