We have a temporal cron job. If we want to change the workflowId, the earlier temporal cron job won’t stop and we have to manually terminate the old workflow. Is there a better way to do this in an automated manner? Can workflows be terminated by type?
Unfortunately the way to stop cron executions is to terminate the currently running one. Would consider moving to new schedules feature if possible in the future as it gives you a lot more functionality.
I have seen users do a workaround for this where they build in a signal handler in their cron workflow and when signal comes in do some cleanup if needed (cancel pending activities for example) and then run an activity that uses client api to terminate this execution.
Can workflows be terminated by type?
you could run visibility query for example something like
ExecutionStatus=“Running” and WorkflowType=“xyz” with ListWorkflowExecutions api and then iterate the results and terminate each one individually if needed.
Thanks!
About schedules, wouldn’t I run into the same problem with schedule Id? If I change it, it won’t delete the previous one?
Idk about specific thing you are trying to change but schedules allow you to update it if that helps.
What if I use spring scheduler to start workflow executions, is there any risk associated with that?
I havent tried that yet but would be interesting to check. Schedules are native to Temporal and would first compare functionalities each gives you to make decision.