For Each Loop

When you need to process each element of an array but would want to allow for parallel execution in order to speed up the processing, the For … Each… loop seems to not work well.
Is there an alternative that would allow parallel execution of the “loop” before continuing when all results are gathered?

Hi Mike,

Are you asking specifically about Loop action with in the workflow or IO flow service based Loop and aggregate data results at the end sort of logic? Please clarify us.

HTH,
RMG

anything that would allow parallel processing, so I’m not bothered if the answer isn’t based on a foreach loop. It’s just that foreach automatically comes to mind (probably based on linguistics)

so step A produces array [a,b,c]. Next step executes same step once for a, once for b and once for c. Order is not important

So you mean to say similar to concurrent processing (where order doesn’t matter)??
But I am also not sure if any OOTB parallel-foreach is available yet apart from handling with custom java code can be achieved or sort of.

Are you using webMethods.io or on premise Integration Server?

For Integration Server, you could probably use messaging to achieve this

If you don’t need to aggregate results, just call pub.publish:publish for every element in your array. The subscriber will process each message asynchronously. With the subscriber trigger settings you can control how much concurrency (i.e. threads) to allow.

If you need to collect all the results, that would be tricky.

It may work to call pub.publish:publishAndWait with async=true for each element and record all the returned “tag” values in an array.

Then call pub.publish:waitForReply in a loop for each tag to gather all the asynchronous processing results

You could publish N documents so that a trigger (which you’ll have to set up) is fired N times.

Yes as Dave mentioned above you can make use of Pub/Sub (Broker/UM) Async architecture and subscription service side collect the aggregate the results for further reporting downstream etc…

HTH,
RMG