Skip to main content

Command reference

What is a Command?#

A Command is a requested action issued by a Worker to the Temporal Cluster after a Workflow Task Execution completes.

The action that the Cluster takes is recorded in the Workflow Execution's Event History as an Event. The Workflow Execution can await on some of the Events that come as a result from some of the Commands.

During a Workflow Task Execution there may be several Commands that are generated. The Commands are batched and sent to the Cluster as part of the Workflow Task Execution completion request, after the Workflow Task has progressed as far as it can with the Workflow function. There will always be WorkflowTaskStarted and WorkflowTaskCompleted Events in the Event History when there is a Workflow Task Execution completion request.

Commands are generated by the use of Workflow APIs in your code

Commands are generated by the use of Workflow APIs in your code

The following Commands are defined in the Temporal gRPC API here: https://github.com/temporalio/api/blob/master/temporal/api/command/v1/message.proto

CompleteWorkflowExecution#

This Command is triggered when the Workflow function execution returns. It indicates to the Cluster that the Workflow Execution is complete. The corresponding Event for this Command is one of the few Events that will be the last in a Workflow Execution Event History.

  • Awaitable: No, a Workflow Execution can not await on the action resulting from this Command.
  • Corresponding Event: WorkflowExecutionCompleted

ContinueAsNewWorkflowExecution#

This Command is triggered when there is a call to Continue-As-New from within the Workflow. The corresponding Event for this Command is one of the few Events that will be the last in a Workflow Execution Event History.

FailWorkflowExecution#

This Command is triggered when the Workflow Execution returns an error or an exception is thrown.

  • Awaitable: No, a Workflow Execution can not await on the action resulting from this Command.
  • Corresponding Event: WorkflowExecutionFailed

CancelWorkflowExecution#

This Command is triggered when the Workflow has successfully cleaned up after receiving a Cancellation Request (which will be present as WorkflowExecutionCancelRequestedEvent in the Event History). The Corresponding Event for this Command is one of the few Events that will be the last in a Workflow Execution Event History.

  • Awaitable: No, a Workflow Execution can not await on the action resulting from this Command.
  • Corresponding Event: WorkflowExecutionCanceled

StartChildWorkflowExecution#

This Command is triggered by a call to spawn a Child Workflow Execution.

SignalExternalWorkflowExecution#

This Command is triggered by a call to Signal another Workflow Execution.

RequestCancelExternalWorkflowExecution#

This Command is triggered by a call to request cancellation of another Workflow Execution.

ScheduleActivityTask#

This Command is triggered by a call to execute an Activity.

  • Awaitable: Yes, a Workflow Execution can await on the action resulting from this Command.
  • Corresponding Event: ActivityTaskScheduled

RequestCancelActivityTask#

This Command is triggered by a call to request the cancellation of an Activity Task.

  • Awaitable: No, a Workflow Execution can not await on the action resulting from this Command.
  • Corresponding Event: ActivityTaskCancelRequested

StartTimer#

This Command is triggered by a call to start a Timer.

  • Awaitable: Yes, a Workflow Execution can await on the action resulting from this Command.
  • Corresponding Event: TimerStarted

CancelTimer#

This Command is triggered by a call to cancel a Timer.

  • Awaitable: No, a Workflow Execution can not await on the action resulting from this Command.
  • Corresponding Event: TimerCanceled

RecordMarker#

This Command is triggered by the SDK.

  • Awaitable: No, a Workflow Execution can not await on the action resulting from this Command.
  • Corresponding Event: MarkerRecorded

UpsertWorkflowSearchAttributes#

This Command is triggered by a call to "upsert" Workflow Search Attributes.

Get notified of updates