Running asynchronous REST call in a parallel fashion

I have an asynchronous REST call, which first sends the query (POST) to the server and returns the task id. Then I need a loop (GET) which regularly checks the jobstatus. This can be solved easilty with Create Empty Data and this works well. Because the REST server can handle multiple queries at time, I wanted parallelize this. However, if parallelized the Create Empty Data does not work at all. I use the @JG, which is local in the scope of the parallelized component, so it should not clash. I have a local #Count and #MaxCount variable within the Create Empty Data.
Initialize Condition looks like: @jobstatus := 'running'; #Count := 0; #MaxCount := ceiling(@Delay*10000);
Condition looks like: #Count++; #Count <= #MaxCount and @JE 'running';
WhenToGenerate is OnNoMoreData
And ProcessDataAction is: PassData
Can you please help?

Comments 1
AC
AC 2021-03-12

Hi Peter. I'm not sure what you mean by "does not work at all". Do you mean the Create Empty Data doesn't create any records or does it stop too early? If you set your jobstatus to something other than 'running' somewhere downstream in the same pipe, the Create Empty Data should stop creating records. I've attached two protocols, one is the parallel execution protocol and the other is the protocol I'm calling from the first protocol using the launchjob endpoint. My Create Empty Data conditions are much simpler. I initialize a global called @continue to be true and sleep 2 seconds so I don't call this too often. I then set the continue variable to 'false' when the job is finished. This seems to work OK for me. Take a look and let me know 

If you want to test this, save the 'Parallel Execution Work Protocol' directly under the Protocols tab and open the 'Call Protocol Asynchronously in Parallel' protocol and run it.

Let me know if you have any questions.

comment imagecomment image