Async calls to REST API

0
Hi I have a microflow that retrieves a list of ids, then retrieves and creates a list of objects based upon those ids. These calls are all made against our RESTful API. Is there any way in which the calls to retrieve the objects may be made in parallel, similar to a parallel foreach in .NET? Alternatively, if the list of ids is passed to the page, is there a widget that runs asynchronously to retrieve the object for display? Cheers, James
asked
2 answers
0

Hi James,

For parallellism you may want to look into CommunityCommons: https://docs.mendix.com/appstore/modules/community-commons-function-library/#46-execute-microflow

or task queues: https://docs.mendix.com/refguide/task-queue/

Depending on the use case, you could also use data views with datasource microflows to make the client retrieve data in parallel. See https://docs.mendix.com/refguide/microflow-source/

It is not exactly the same as a parallel forEach in .net, but would one of these solutions fit your needs?

answered
0

Hi Michiel, thank you for your reply. I’ve taken a look at the suggested approaches.

In the case of using the actions CommunityCommons.RunMicroflowAsyncInQueue or CommunityCommons.ExecuteMicroflowInBackground, I may be misunderstanding these, but the return type appears to be a boolean, whereas I would like it to be the individual object that I may then append to a list.

Ideally, I’d like the bit in the loop to call out in parallel, or asynchronously, and append the result to the claims. I don’t believe that this is possible?

The other approach is via the UI, as below:

Is this the data source microflow solution? In which case, I’m not convinced that the calls are happening in parallel. The page produced appears to be filling in the values sequentially, from the top of the page to the bottom. I will check though,

Thank you

 

answered