request_cancel_workflow_execution ( $opt )

Records a WorkflowExecutionCancelRequested event in the currently running workflow execution identified by the given domain, workflowId, and runId. This logically requests the cancellation of the workflow execution as a whole. It is up to the decider to take appropriate actions when it receives an execution history with this event.

If the runId is not specified, the WorkflowExecutionCancelRequested event is recorded in the history of the current open workflow execution with the specified workflowId in the domain.

Because this action allows the workflow to properly clean up and gracefully close, it should be used instead of TerminateWorkflowExecution when possible.

Access Control

You can use IAM policies to control this action’s access to Amazon SWF resources as follows:

  • Use a Resource element with the domain name to limit the action to only specified domains.
  • Use an Action element to allow or deny permission to call this action.
  • You cannot use an IAM policy to constrain this action’s parameters.

If the caller does not have sufficient permissions to invoke the action, or the parameter values fall outside the specified constraints, the action fails by throwing OperationNotPermitted. For details and example IAM policies, see Using IAM to Manage Access to Amazon SWF Workflows.

Access

public

Parameters

Parameter

Type

Required

Description

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • domain - string - Required - The name of the domain containing the workflow execution to cancel.
  • workflowId - string - Required - The workflowId of the workflow execution to cancel.
  • runId - string - Optional - The runId of the workflow execution to cancel.
  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Signal and Cancel a Workflow Execution

Shows an example of signaling and canceling a workflow execution.

This sample uses anonymous functions, which are only available in PHP 5.3+. For PHP 5.2 users, you must used named functions instead of anonymous ones.

$swf = new AmazonSWF();

// Setup
$timestamp = time();
$workflow_domain = 'my-domain' . $timestamp;
$workflow_type_name = 'my-workflow-type';
$activity_type_name = 'my-activity-type';

//-----------------------------------------------------------------//
// Signal the workflow with an event and new data

echo '# Signaling the workflow with an event and new data...' . PHP_EOL;
$signal = $swf->signal_workflow_execution(array(
	'domain'     => $workflow_domain,
	'workflowId' => 'my-workflow-execution',
	'runId'      => $run_id,
	'signalName' => 'my-test-signal',
	'input'      => 'data for my test signal'
));

if ($signal->isOK())
{
	echo 'Successfully signaled the workflow with an event and new data.' . PHP_EOL;
}
else
{
	echo 'Failed to signal the workflow an new event.' . PHP_EOL;
}

echo PHP_EOL;

//-----------------------------------------------------------------//
// Cancel a workflow execution

echo '# Canceling the workflow execution...' . PHP_EOL;
$cancel = $swf->request_cancel_workflow_execution(array(
	'domain'     => $workflow_domain,
	'workflowId' => 'my-workflow-execution',
	'runId'      => $run_id
));

if ($cancel->isOK())
{
	echo 'Successfully canceled the workflow.' . PHP_EOL;
}
else
{
	echo 'Failed to cancel the workflow.' . PHP_EOL;
}

echo PHP_EOL;

Source

Method defined in services/swf.class.php | Toggle source view (6 lines) | View on GitHub

public function request_cancel_workflow_execution($opt = null)
{
    if (!$opt) $opt = array();
    
    return $this->authenticate('RequestCancelWorkflowExecution', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback