Looping Parallel SubProcess and Shared Data...

Discussions about modeling, execution and management of process/application data.
Forum rules
Make sure every topic contains information about your LSPS version and if relevant also your server OS, client OS, database name and version, and application server name and version.
cbmeeks
 
Posts: 59
Joined: Wed Aug 07, 2013 11:28 pm

Looping Parallel SubProcess and Shared Data...

Thu Jul 30, 2015 10:24 pm

OK, so I have a SubProcess that is set to Loop with Multi-Instance and Ordering of Parallel.

The iterator is "rdc".

During each iteration of the parallel sub-process, I'm seeing the "rdc" object correctly use the distinct code. For example, there are three RDC's in the collection with codes like "CHA", "DAL" and "KZOO". So each iteration correctly uses "CHA", "DAL" or "KZOO". So this is nice.

Now, in the iteration (sub-process), I also reference a global variable called "ResponseCode" which is just an Integer. In this iteration, I perform an HttpCall that is bound to that ResponseCode and then I log it.

The log is showing the identical value for each instance. However, I cannot determine if each instance gets its own copy of ResponseCode or are they each pointing to the same object via multiple references?

Hope that makes sense.

Giovanni Rimassa
 
Posts: 7
Joined: Mon Feb 27, 2012 2:52 pm

Re: Looping Parallel SubProcess and Shared Data...

Fri Jul 31, 2015 12:09 am

Hi cbmeeks,

with multi-instance activities, it works like this:
  • Module-global variables (i.e., defined in a .vars file) are shared across activity instances (that is, in your example, all the instances point to the same object via multiple references)
  • Process-local variables (i.e., defined by clicking on the "Variables" tab of the process properties) are also shared across activity instances
  • Sub-process local variables of the multi-instance activity (i.e., defined by clicking on the "Variables" tab of the sub-process itself) are not shared: each instance has its own separate copy
  • Local variables of all sub-processes contained within the multi-instance one, at any nesting level, are also not shared

In your case, if you want to get a vector of all the HttpCall response codes for each value of the iterator, I could imagine two ways.
  • Define some record type that contains not only the call parameter but also the result and the response code (basically a future variable: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Future.html). You will then use a list of such records in the For Each property and the iterator will be a record, so that each activity instance gets a copy of all its fields, including the response code
  • Define a ResponseCodes global variable of type Map<String, Integer> and define a sub-process local ResponseCode variable of type Integer. Then, in the assignment for the outgoing flow of your HttpCall task, you write something like ResponseCodes := add(ResponseCodes, rdc, ResponseCode) to get the association of each iterator value with its corresponding response code.

cbmeeks
 
Posts: 59
Joined: Wed Aug 07, 2013 11:28 pm

Re: Looping Parallel SubProcess and Shared Data...

Fri Jul 31, 2015 12:09 am

Actually, I just answered my own question.

When I define the parent sub-process to loop sequentially, each temp variable holds its state in the context of the individual sub-process iteration.

But when running in parallel, each instance "steps" on each other and the data is shared. This makes sense.

Now the question is, if I spawn X number of sub-processes, how can I define global variables that are confined to the scope of each individual process?

Being able to perform an HttpCall to different URLS in parallel is very beneficial!

Thanks


**EDIT**

I just saw your response! I will read through it....

Thanks



**EDIT 2**

Thank you for the reply. That makes sense.

I will try those suggestions out.

Thanks!

cbmeeks
 
Posts: 59
Joined: Wed Aug 07, 2013 11:28 pm

Re: Looping Parallel SubProcess and Shared Data...

Fri Jul 31, 2015 12:49 am

Giovanni,

That worked like a treat. Exactly what I needed.

Thanks!

Return to Data modeling

Who is online

Users browsing this forum: No registered users and 1 guest