Batch Signals: How to send a signal to multiple running workflows?


I have a use case where I have multiple executions of a workflow running at the same time. As per the docs, each execution has a unique workflowId.

If I need to send a signal to all these workflows to update their behavior in real time, what is the best way to send this signal without having to iterate over all my running workflows and sending an individual signal to each?

Is there a way to send a signal to multiple workflows at the same time via the Java SDK?

I see that there is a way via the CLI.

tctl --ns samples-namespace batch start --query "WorkflowType='main.SampleParentWorkflow' AND CloseTime=missing" --reason "test" --bt signal --sig testname

This batch job will be operating on 5 workflows.

Please confirm[Yes/No]:yes
"jobId": "<batch-job-id>",
"msg": "batch job is started"
1 Like

Unfortunately there is no clean API to invoke this functionality in Java. For now you’ll have to invoke the CLI as a subprocess.

Note that batch operations are supported only if you run Temporal with Elastic Search integration.

Any chance this can be a feature request? I assume the ability to mass signal workflows will be a use case that many will have and an easy way to do so via the Java SDK makes sense?

I can experiment with the CLI subprocess. Alternatively, if needed I could also just add all the workflowIds to a kafka queue and let a worker create a workflow stub to signal each individual one. I’m not sure what the implication of that is but I can try out both ways.

It is absolutely a feature request and we plan to make this experience much cleaner.

1 Like