TLDR
I have 2 workflows, 1 parent and 1 child. I want parent and its activities to run in one worker, while child and its activities to run in another worker. I tried to use session but it didn’t work.
Did you check the file processing example?
Yes
How do you use session in parent workflow?
childWorkflowOpts := workflow.ChildWorkflowOptions{
ParentClosePolicy: enums.PARENT_CLOSE_POLICY_REQUEST_CANCEL,
}
ctx = workflow.WithChildOptions(ctx, childWorkflowOpts)
wctx := createDefaultContext(ctx)// Create workflow session
so := &workflow.SessionOptions{
CreationTimeout: time.Minute,
ExecutionTimeout: monthTime,
}
wctx, err := workflow.CreateSession(wctx, so)
if err != nil {
logWorkflowError(wctx, “Failed to create workflow session”, err)
return nil, err
}…
// execute activity
err = workflow.ExecuteActivity(wctx, e.createWorkspaceParent, workspaceParent).Get(wctx, nil)
if err != nil {
…
}
How do you spawn the child workflow?
futures = append(futures, workflow.ExecuteChildWorkflow(
wctx, // same context as above
…))
err = futures[i].GetChildWorkflowExecution().Get(wctx, nil)
How do you use session in child workflow?
wctx := createDefaultContext(ctx)
// Create workflow session
so := &workflow.SessionOptions{
CreationTimeout: time.Minute,
ExecutionTimeout: monthTime,
}
wctx, err := workflow.CreateSession(wctx, so)
if err != nil {
…
}…
// execute activity
err = workflow.ExecuteActivity(wctx, e.activities[0].Name, workspaceChild).Get(wctx, nil)
if err != nil {
…
}
Did you set EnableSessionWorker to true in worker options?
Yes
How do you know the activities are running in different workers?
I inspected the logs for both workers. I could see they were executing activities from both workflows.
Are those 2 workers listening to the same task queue?
Yes
Can someone please suggest what might be the cause here?
Thanks,
Shi