How to distinguish between parallel Promises that succeeded and failed?

thanks Maxim,

runBlocking 

solved it, as follows (this is an activity function):

    override fun updateSessionToDB(bulkId: String, sessionUpdateRequest: SessionUpdateDbRequest): SessionUpdateDbResponse {
        val sessionId = sessionUpdateRequest.sessionId
        val sessionResponse = runBlocking {
            agendaService.updateSessionToDbForBulk(
                accountId = sessionUpdateRequest.accountId,
                eventId = sessionUpdateRequest.eventId,
                sessionId = sessionId,
                patchSessionRequest = sessionUpdateRequest.data
            )
        }
        return sessionResponse
    }

in that way, the activity does not have to be suspended and it can call a suspend function (updateSessionToDbForBulk). in case of parallel, I call Kotlin’s “async” within the “runBlocking”.

Note that you can implement an activity asynchronously using DoNotCompleteOnReturn.

thanks for the replies.

back to workflows, I have the following question:
in your documentation it is said that:

“There is no need in explicit synchronization because multi-threaded code inside a Workflow is executed one thread at a time and under a global lock”

but in your example we can see that (Temporal Java SDK developer's guide | Temporal Documentation. ):

      // Download all files in parallel.
      for (String sourceFilename : args.getSourceFilenames()) {
        Promise<String> localName =
            Async.function(activities::download, args.getSourceBucketName(), sourceFilename);
        localNamePromises.add(localName);
      }

my questions are:

  1. are the downloads of the files really parallel, or only concurrent?
  2. if I’d like to limit the number of threads opened by Async.function, how would you suggest to do that?
  3. in the documentation you say:

“Do not use any mutable global variables in your Workflow implementations. This will assure that multiple Workflow instances are fully isolated”

what do you mean by “global variables”. can’t I use a list\map as a workflow variable? in this example moneybatch we can see such mutable (Set) collection

Thanks,
Shai

adding another question to this thread:

if some workflow has default execution timeout (which is infinite), and the pod on which it’s running on crashes, will it be retried? if yes - how and when? if not - should I set the timeout to some finite time?

Thanks,
Shai

Could you please ask in a separate thread? It really helps to ask each independent question in separate one.