How to make activity use the same worker?

My DownloadActivity downloads files, stores them in filesystem and returns paths.
I have 2 worker pods, so when control is back to workflow it can’t find stored files, because workflow is executed by another pod.
In the main workflow I assemble payload and pass them to ChildWorkflows. Then I do cleanup.

I wanted to use Sessions, but they work from activity to activity.

Another thing I tried is ExecuteLocalActivity but that doesn’t seem to suit this case. Getting this
"Error":"expected 3 args for function: DownloadActivity but found 1". However I’m using it the same way as I was doing ExecuteActivity.

What would you recommend doing for activity to use the same worker as the workflow?

Sessions is the recommended way to run multiple activities on the same worker.

Did you follow this sample? samples-go/workflow.go at bb74f9b5ee92f4ab38400bfb4f7823b94992af6f · temporalio/samples-go · GitHub

Thank you, yes I saw this sample.
But key difference here is that actions I want to do after first activity is in the workflow, not in another activity. That’s why I need first activity to execute in the same worker as the workflow.

I am doing that in the workflow because I need the payload to be sent in ChildWorkflow, which can be executed only from workflow

You don’t need the activity to run on the same worker as the workflow, you shouldn’t try to access those files directly from the workflow at all, always use an activity to communicate with external resources.
If the payload is very large, you’ll need to return pointers to external storage or use a unique per-worker task queue to reference the same host cross multiple workflow executions.

Yeah exactly, I don’t want to return large payloads from activity.
As one of the solutions I was thinking to be using shared vol for all pods.
But this per-worker task-queue sounds promising. Will try that

There’s a TypeScript sample that shows how to achieve that.

1 Like