getActivityTask method

Future<GetActivityTaskOutput> getActivityTask({
  1. required String activityArn,
  2. String? workerName,
})

Used by workers to retrieve a task (with the specified activity ARN) which has been scheduled for execution by a running state machine. This initiates a long poll, where the service holds the HTTP connection open and responds as soon as a task becomes available (i.e. an execution of a task of this type is needed.) The maximum time the service holds on to the request before responding is 60 seconds. If no task is available within 60 seconds, the poll returns a taskToken with a null string.

Polling with GetActivityTask can cause latency in some implementations. See Avoid Latency When Polling for Activity Tasks in the Step Functions Developer Guide.

May throw ActivityDoesNotExist. May throw ActivityWorkerLimitExceeded. May throw InvalidArn.

Parameter activityArn : The Amazon Resource Name (ARN) of the activity to retrieve tasks from (assigned when you create the task using CreateActivity.)

Parameter workerName : You can provide an arbitrary name in order to identify the worker that the task is assigned to. This name is used when it is logged in the execution history.

Implementation

Future<GetActivityTaskOutput> getActivityTask({
  required String activityArn,
  String? workerName,
}) async {
  ArgumentError.checkNotNull(activityArn, 'activityArn');
  _s.validateStringLength(
    'activityArn',
    activityArn,
    1,
    256,
    isRequired: true,
  );
  _s.validateStringLength(
    'workerName',
    workerName,
    1,
    80,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'AWSStepFunctions.GetActivityTask'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'activityArn': activityArn,
      if (workerName != null) 'workerName': workerName,
    },
  );

  return GetActivityTaskOutput.fromJson(jsonResponse.body);
}