Sending Signals to Workflows
In certain scenarios, there might arise a need to transmit signals to workflows for purposes such as pausing, terminating, or restarting them. There are different ways through which you can achieve this.
In this document, let’s look at the different ways to send signals to your workflows in a production environment.
Pause Workflow
You can pause the workflows to wait for external signals. There are different methods to pause your workflow.
Using API
Once the workflow is run, the workflowId will be generated. Use the following API with the workflowId as the input payload to pause your workflow:
PUT /workflow/{workflowId}/pause
SDKs
- Java
- Go
- Python
- C#
- JavaScript
- Typescript
- Clojure
BulkResponse pauseWorkflow(List<String> workflowIds) throws ApiException
func (e *WorkflowExecutor) Pause(workflowId string) error
WorkflowResourceApi.pause_workflow1(self, workflow_id, **kwargs)
void WorkflowResourceApi.PauseWorkflow(string workflowId)
WorkflowExecutor.pauseWorkflow(
workflowId: string,
): CancelablePromise<any>
WorkflowExecutor.pauseWorkflow(
workflowId: string,
): CancelablePromise<any>
(workflow-resource/pause-workflow [options workflow-id])
From Conductor UI
From the workflow executions page, click Actions, and choose Pause.
Resume Workflow
You can resume the paused workflows once the purpose is served.
Using API
Use the following API with the workflowId as the input parameter to resume your paused workflow:
PUT /workflow/{workflowId}/resume
SDKs
- Java
- Go
- Python
- C#
- JavaScript
- Typescript
- Clojure
BulkResponse resumeWorkflow(List<String> workflowIds) throws ApiException
func (e *WorkflowExecutor) Resume(workflowId string) error
WorkflowResourceApi.resume_workflow1(self, workflow_id, **kwargs)
void WorkflowResourceApi.ResumeWorkflow(string workflowId)
WorkflowExecutor.resume(
workflowId: string,
): CancelablePromise<any>
WorkflowExecutor.resume(
workflowId: string,
): CancelablePromise<any>
(workflow-resource/resume-workflow [options workflow-id])
From Conductor UI
From the workflow executions page, click Actions, and choose Resume.
Restart Workflow
In certain situations, your workflow may fail due to any reason, and it will reach the terminated state. In such cases, you can quickly restart the workflow execution from the beginning.
Using API
With the workflowId as the input parameter, use the following API to restart the workflow from the beginning with the same input. This operation has no effect when called on a workflow that is not in a terminal status.
POST /workflow/{workflowId}/restart
SDKs
- Java
- Go
- Python
- C#
- JavaScript
- Typescript
- Clojure
BulkResponse restartWorkflow(List<String> workflowIds, Boolean useLatestDefinitions) throws ApiException
func (e *WorkflowExecutor) Restart(workflowId string, useLatestDefinition bool) error
WorkflowResourceApi.restart1(self, workflow_id, **kwargs)
void WorkflowResourceApi.Restart(string workflowId, bool? useLatestDefinitions = null)
WorkflowExecutor.restart(
workflowId: string,
useLatestDefinitions: boolean,
): CancelablePromise<void>
WorkflowExecutor.restart(
workflowId: string,
useLatestDefinitions: boolean,
): CancelablePromise<void>
(workflow-resource/restart-workflow [options workflow-id])
From Conductor UI
From the workflow executions page, click Actions, and you can choose to restart workflows either using the same definition or with the latest definitions.
- Restart with Current Definitions - Restart the workflow from the beginning using the same version of the workflow definition that originally ran this execution. This is useful if the workflow definition has changed and we want to retain this instance in the original version.
- Restart with Latest Definitions - Restart this workflow from the beginning using the latest definition of the workflow. If you’ve made changes to the definition, you could use this option to rerun the flow with the latest version.
Rerun Workflow
The restart option restarts the workflow with either the current or latest definitions. However, if you want to run a new instance of the workflow by making changes to the workflow inputs, correlation ID, or task to domain mapping, you can utilize the rerun option.
Using API for rerunning a workflow from a specific task
Once you have the workflowId, you can rerun the workflow from a specific task using the following API. Get the task execution ID from the UI and include it in the API.
POST /workflow/{workflowId}/rerun
{
"reRunFromTaskId": "TASK_ID_TO_REREUN_FROM",
"taskInput": {
//Extra inputs to the task
},
"workflowInput": {
//Changes to workflow inputs as part of re-run
}
}
SDKs
- Java
- Go
- Python
- C#
- JavaScript
- Typescript
- Clojure
String rerunWorkflow(String workflowId, RerunWorkflowRequest rerunWorkflowRequest)
func (e *WorkflowExecutor) ReRun(workflowId string, reRunRequest model.RerunWorkflowRequest) (id string, error error)
WorkflowResourceApi.rerun(self, body, workflow_id, **kwargs)
string WorkflowResourceApi.Rerun(RerunWorkflowRequest body, string workflowId)
WorkflowExecutor.rerun(
workflowId: string,
requestBody: RerunWorkflowRequest,
): CancelablePromise<string>
WorkflowResourceService.rerun(
workflowId: string,
requestBody: RerunWorkflowRequest,
): CancelablePromise<string>
(workflow-resource/rerun-workflow [options workflow-id rerun-wf-request])
From Conductor UI
From the workflow executions page, click Actions and choose Re-run Workflow. Clicking on this takes us to the Run Workflow page, where you can rerun the workflow. While running, you can change the workflow input parameters and task to domain mapping.
Retry from Failed Task
Suppose your workflow fails at a task; you can retry the workflow from the failed task.
Using API
Once you have the workflowId, you can retry a failed workflow from the failed task using the following API.
POST /workflow/{workflowId}/retry
SDKs
- Java
- Go
- Python
- C#
- JavaScript
- Typescript
- Clojure
BulkResponse retryWorkflow(List<String> workflowIds) throws ApiException
func (e *WorkflowExecutor) Retry(workflowId string, resumeSubworkflowTasks bool) error
WorkflowResourceApi.retry1(self, workflow_id, **kwargs)
void WorkflowResourceApi.Retry(string workflowId, bool? resumeSubworkflowTasks = null)
WorkflowExecutor.retry(
workflowId: string,
resumeSubworkflowTasks: boolean,
): CancelablePromise<void>
WorkflowExecutor.retry(
workflowId: string,
resumeSubworkflowTasks: boolean,
): CancelablePromise<void>
(workflow-resource/retry-last-failed-task [options workflow-id resume-subworkflow-tasks])
From Conductor UI
From the workflow executions page, click Actions, and choose Retry - From failed task.
Manually Updating Task Status in a Workflow
Certain situations may require you to manually update the task status in a workflow.
Using API
By providing the workflowId, task reference name, and the task status as the input, you can use the following API to update a task status manually:
POST /tasks/{workflowId}/{taskRefName}/{status}
SDKs
- Java
- Go
- Python
- C#
- JavaScript
- Typescript
- Clojure
String OrkesTaskClient.updateTaskByRefName(Map<String, Object> output, String workflowId, String taskRefName, String status) throws ApiException
func (*WorkflowExecutor) UpdateTaskByRefName(taskRefName string, workflowInstanceId string, status model.TaskResultStatus, output interface{}) error
TaskResourceApi.update_task1(taskOutput, workflow_id, task_ref_name, status, **kwargs)
string TaskResourceApi.UpdateTask(Dictionary<string, Object> taskOutput, string workflowId, string taskRefName, string status, string workerid = null)
TaskResourceService.updateTask(
workflowId: string,
taskRefName: string,
status: 'IN_PROGRESS' | 'FAILED' | 'FAILED_WITH_TERMINAL_ERROR' | 'COMPLETED',
taskOutput: Record<string, any>,
): CancelablePromise<string>
TaskResourceService.updateTask(
workflowId: string,
taskRefName: string,
status: 'IN_PROGRESS' | 'FAILED' | 'FAILED_WITH_TERMINAL_ERROR' | 'COMPLETED',
taskOutput: Record<string, any>,
): CancelablePromise<string>
(task-resource/update-task-by-reference-name options workflow-id task-reference-name status update-req)
Using Conductor UI
- Navigate to the workflow execution, and click on the task whose status is to be updated manually.
- From the summary tab, select the status under the field Update task.
Terminate Workflow
In certain situations, you may want to send signals to terminate the workflows.
Using API
Use the following API with the workflowId as the input parameter to terminate your running workflow:
DELETE /workflow/{workflowId}
SDKs
- Java
- Go
- Python
- C#
- JavaScript
- Typescript
- Clojure
void terminateWorkflow(String workflowId, String reason)
func (e *WorkflowExecutor) Terminate(workflowId string, reason string) error
WorkflowResourceApi.terminate1(self, workflow_id, **kwargs)
void WorkflowResourceApi.Terminate(string workflowId, string reason = null, bool? triggerFailureWorkflow = null)
WorkflowExecutor.terminate(
workflowId: string,
reason: string,
): CancelablePromise<any>
WorkflowExecutor.terminate(
workflowId: string,
reason: string,
): CancelablePromise<any>
(workflow-resource/terminate-workflow [options workflow-id & args])
Using Conductor UI
From the workflow executions page, click Actions > Terminate.