Question
Yone Moreno · Mar 27, 2020

How could we paralelize two different calls?

Hello,

We are developing a BP where we would need to call at the same time to get appointments in two external systems. So then, we would need two threads, one for primary care appointments, and other for specialist appointments . We need to paralelize both calls because of both of them require some time and we would need to shorten it as much as possible.

 

We are currently using a flow:

And inside the flow we have two sequences, the first one for specialists appointments, where we get them with a rest operation, then transform the json string to a object, and then we convert it to match the primary care appointments format:

 

And then, in other sequence we have the primary cade appointments, where we get them with a soap operation, parse it to xml and return:

 

However we do have a question, how do we make sure that both calls are being held concurrently?

 

Because of if we see the trace, it is being requested the specialists appointments and then the primary appointments, (just miliseconds of difference)

 

To be precise, the behaviour we would need is to send both calls without having to wait for getting the outer system answer.

 

How could we paralelize two different calls?

 

We have read:

 

0
0 199
Discussion (3)1
Log in or sign up to continue

Send async calls.

Wait for response from one or both calls.

Hello Eduard Lebedyuk, thanks for your answer.

We have tried to send two async calls, and then use a <sync> to wait for both responses. We thought the BPL execution flow would stop at <sync> until it gets all responses from the async calls. However we observe that both sync calls are sent and then the execution flow continues beyond <sync>.

To give more context, we are calling for specialists appointments, then for primary appointments, after that we have the sync, and finally some transformation and code as follows:

Being the trace, the following, where we see the two asyn call being sent:

However because of the execution flow continues after <sync> without having both responses, we have in our context empty responses, so then the transformation fails:

Besides we do get the responses, however they arrive after they are needed, because of primary appointments return after the Transform attempt was made, and the specialists appointments are retrieved after BPL sends a response to the service (which means we could not use the specialists appointments anymore).

The question is: how could we achieve to wait and stop BPL execution flow, until we do get both async calls' responses?

Do not specify a timeout or specify a longer timeout.

In your example if the response is taking more than 15 seconds the sync activity will complete

Here's a minimal example for you. BP sends 2 async calls and waits for them in sync activity:

And Visual Trace looks like this:

To test:

  1. Download code here.
  2. Import and compile.
  3. Open and start production.
  4. Send Ens.Request test request to BP.