Multi workers instances

Hi, i have an architecture based on pub/sub and have multiple containers.
Each container basically listen the topic for new messages, when he gets one, run a Workflow instance.
Now, the worflow has different activities (read/write from db, from filesystem ecc.).
The problem seems to be that a workflow sometimes does some activities on 1 container and some other on another container.
This of course is a problem, since the Files to upload / download are saved on filesystem of the first container, so if another container execute the part of upload without have the file on its filesystem the Worflow execution fails.

My questions is:

  1. Is possibile to create some kind of “transaction”, meaning “all this part must be executed totally by 1 worker”


yes you could use something call Session, check Sessions | Temporal documentation

1 Like

I see, yeah that’s the idea but i dont get 2 things:

  1. I’m using Java SDK and i cant find the Context or CreateSession() method, how is it possibile?
  2. I see that isn’t possibile have more than 1 Worker per process if using this feature, why is that?


Sorry I’m not familiar with the java sdk, so I will let someone confirm if it’s possible or not.
For the 2. It’s just to avoid to have multiple session to run on the host if it’s what you want to avoid. As the session is per worker and not per host. Check in the QA session Sessions | Temporal documentation

For Java see the file processing sample: samples-java/src/main/java/io/temporal/samples/fileprocessing at master · temporalio/samples-java

Hope this helps.