Is it possible to restart activity

HI Team,

Is it possible to restart activity by API? For example, after a few retires, the activity will enter error or pending state, an external restart will be triggered after dependencies’ issues are fixed.

Thanks in advance.

I would strongly recommend using built in primitives.

You have couple options here:

  1. Setting right activity retry policy that would work in your scenario and avoid manual intervention in the first place.
  2. You may cancel activity from the workflow code by starting activity in the cancellation scope and cancelling the scope. This process can be triggered by a signal to the workflow if you want to initiate it externally.
  3. From the operational perspective, you may also consider resetting workflow to the last completed workflow task (before your last activity started), which would start a new workflow run triggering activity again. I think this option is closest to what you’ve asked for. For example here is the CLI command tctl wf reset --wid $myid --reason "some" --reset_type LastWorkflowTask
    You can also do it using an API:
    WorkflowServiceStubs service = WorkflowServiceStubs.newInstance();    

Let me know if this is helpful.

Thank you Vitaly, this is very helpful, I will take the third option.