I’ve confirmed that a workflow can specify a task queue by using ActivityOptions and creating a new context for each activity invocation.
As per the title, I’m thinking of whether I can define a workflow with 2 activities that are bound to 2 workers respectively.
When running the worker/main.go like the following, it initiates only w1. Apparently, it’s due to worker.InterruptCh() as the argument of the Run function.
func main() {
c, err := client.Dial(client.Options{})
if err != nil {
log.Fatalln("Unable to create client", err)
}
defer c.Close()
w1 := worker.New(c, MyTaskQueue1, worker.Options{})
w2 := worker.New(c, MyTaskQueue2, worker.Options{})
w1.RegisterWorkflow(MyWorkflow)
w1.RegisterActivity(MyActivity1)
w2.RegisterActivity(MyActivity2)
err = w1.Run(worker.InterruptCh())
if err != nil {
log.Fatal("Unable to start worker", err)
}
err = w2.Run(worker.InterruptCh())
if err != nil {
log.Fatal("Unable to start worker", err)
}
Apparently, a worker executes tasks so having multiple workers help execute tasks faster if tasks are enormous. For example, a workflow that spawns child workflows with many activities. Going back to my question, Is it possible to define a workflow with 2 activities that are bound to 2 workers respectively?