

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

# EventBridge para alterações no status de execução do Amazon SWF
<a name="ev-events"></a>

Você usa EventBridge a Amazon para responder a mudanças de estado ou eventos em um AWS recurso. Quando o Amazon SWF emite um evento, ele sempre vai para o barramento de EventBridge eventos padrão da sua conta. Você pode criar uma regra para eventos, associá-la ao barramento de eventos padrão e especificar uma ação de destino a ser tomada ao EventBridge receber um evento que corresponda à regra. Dessa forma, você pode monitorar seus fluxos de trabalho sem precisar fazer pesquisas constantes usando a API [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_GetWorkflowExecutionHistory.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_GetWorkflowExecutionHistory.html). Com base nas mudanças nas execuções do fluxo de trabalho, você pode usar um EventBridge destino para chamar AWS Lambda funções, publicar mensagens em tópicos do Amazon Simple Notification Service (Amazon SNS) e muito mais.

Você pode ver o conteúdo completo de um evento de alteração do status de execução usando [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DescribeWorkflowExecution.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DescribeWorkflowExecution.html).

Para obter mais informações, consulte o [Guia EventBridge do usuário da Amazon](https://docs.aws.amazon.com/eventbridge/latest/userguide/). 

## EventBridge eventos
<a name="ev-events-supported"></a>

Os tipos de eventos do histórico contêm as alterações do estado de execução. A `detail` seção de cada evento contém pelo menos os seguintes parâmetros:
+ `eventId`: o ID do evento mostrado por GetWorkflowExecutionHistory.
+ `workflowExecutionDetail`: o estado do fluxo de trabalho quando o evento foi emitido.
+ `eventType`: o tipo de evento histórico, um dos seguintes:
  + `ActivityTaskCanceled`
  + `ActivityTaskFailed`
  + `ActivityTaskTimedOut`
  + `WorkflowExecutionCanceled`
  + `WorkflowExecutionCompleted`
  + `WorkflowExecutionFailed`
  + `WorkflowExecutionStarted`
  + `WorkflowExecutionTerminated`
  + `WorkflowExecutionTimedOut`
  + `WorkflowExecutionContinuedAsNew`
  + `CancelTimerFailed`
  + `CancelWorkflowExecutionFailed`
  + `ChildWorkflowExecutionFailed`
  + `ChildWorkflowExecutionTimedOut`
  + `CompleteWorkflowExecutionFailed`
  + `ContinueAsNewWorkflowExecutionFailed`
  + `DecisionTaskTimedOut`
  + `FailWorkflowExecutionFailed`
  + `RecordMarkerFailed`
  + `RequestCancelActivityTaskFailed`
  + `RequestCancelExternalWorkflowExecutionFailed`
  + `ScheduleActivityTaskFailed`
  + `SignalExternalWorkflowExecutionFailed`
  + `StartActivityTaskFailed`
  + `StartChildWorkflowExecutionFailed`
  + `StartTimerFailed`
  + `TimerCanceled`
  + `LambdaFunctionFailed`
  + `LambdaFunctionTimedOut`
  + `StartLambdaFunctionFailed`
  + `ScheduleLambdaFunctionFailed`

## Exemplos de eventos do Amazon SWF
<a name="ev-events-events"></a>

Veja a seguir exemplos do Amazon SWF enviando eventos para: EventBridge 

**Topics**
+ [Execução iniciada](#ev-events-execution-started)
+ [Execução concluída](#ev-events-execution-completed)
+ [Falha na execução](#ev-events-execution-failed)
+ [A execução atingiu o tempo limite](#ev-events-execution-timed-out)
+ [Execução encerrada](#ev-events-execution-aborted)

Em cada caso, a seção `detail` em dados de evento fornece as mesmas informações da API do [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DescribeWorkflowExecution.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DescribeWorkflowExecution.html). O campo `executionStatus` indica o status da execução no momento em que o evento foi enviado, seja `OPEN` ou `CLOSED`. 

### Execução iniciada
<a name="ev-events-execution-started"></a>

```
{
  "version": "0",
  "id": "444444444444",
  "detail-type": "Simple Workflow Execution State Change",
  "source": "aws.swf",
  "account": "444444444444",
  "time": "2020-05-08T15:57:38Z",
  "region": "us-east-1",
  "resources": [
    "arn:aws:swf:us-east-1:444444444444:/domain/SimpleWorkflowUserSimulator"
  ],
  "detail": {
    "eventId": 1,
    "eventType": "WorkflowExecutionStarted",
    "workflowExecutionDetail": {
      "executionInfo": {
        "execution": {
          "workflowId": "123456789012",
          "runId": "AKIAIOSFODNN7EXAMPLE"
        },
        "workflowType": {
          "name": "SimpleWorkflowUserSimulator",
          "version": "myWorkflow"
        },
        "startTimestamp": 1588953458484,
        "closeTimestamp": null,
        "executionStatus": "OPEN",
        "closeStatus": null,
        "parent": null,
        "parentExecutionArn": null,
        "tagList": null,
        "cancelRequested": false
      },
      "executionConfiguration": {
        "taskStartToCloseTimeout": "60",
        "executionStartToCloseTimeout": "1000",
        "taskList": {
          "name": "444444444444"
        },
        "taskPriority": null,
        "childPolicy": "ABANDON",
        "lambdaRole": "arn:aws:iam::444444444444:role/BasicSWFLambdaExecution"
      },
      "openCounts": {
        "openActivityTasks": 0,
        "openDecisionTasks": 1,
        "openTimers": 0,
        "openChildWorkflowExecutions": 0,
        "openLambdaFunctions": 0
      },
      "latestActivityTaskTimestamp": null,
    }
  }
}
```

### Execução concluída
<a name="ev-events-execution-completed"></a>

```
{
  "version": "0",
  "id": "1111-2222-3333",
  "detail-type": "Simple Workflow Execution State Change",
  "source": "aws.swf",
  "account": "444455556666",
  "time": "2020-05-08T15:57:39Z",
  "region": "us-east-1",
  "resources": [
    "arn:aws:swf:us-east-1:444455556666:/domain/SimpleWorkflowUserSimulator"
  ],
  "detail": {
    "eventId": 35,
    "eventType": "WorkflowExecutionCompleted",
    "workflowExecutionDetail": {
      "executionInfo": {
        "execution": {
          "workflowId": "1234-5678-9012",
          "runId": "777788889999"
        },
        "workflowType": {
          "name": "SimpleWorkflowUserSimulator",
          "version": "myWorkflow"
        },
        "startTimestamp": 1588953458820,
        "closeTimestamp": 1588953459448,
        "executionStatus": "CLOSED",
        "closeStatus": "COMPLETED",
        "parent": null,
        "parentExecutionArn": null,
        "tagList": null,
        "cancelRequested": false
      },
      "executionConfiguration": {
        "taskStartToCloseTimeout": "60",
        "executionStartToCloseTimeout": "1000",
        "taskList": {
          "name": "1111-1111-1111"
        },
        "taskPriority": null,
        "childPolicy": "ABANDON",
        "lambdaRole": "arn:aws:iam::444455556666:role/BasicSWFLambdaExecution"
      },
      "openCounts": {
        "openActivityTasks": 0,
        "openDecisionTasks": 0,
        "openTimers": 0,
        "openChildWorkflowExecutions": 0,
        "openLambdaFunctions": 0
      },
      "latestActivityTaskTimestamp": 1588953459402,
    }
  }
}
```

### Falha na execução
<a name="ev-events-execution-failed"></a>

```
{
  "version": "0",
  "id": "1111-2222-3333",
  "detail-type": "Simple Workflow Execution State Change",
  "source": "aws.swf",
  "account": "444455556666",
  "time": "2020-05-08T15:57:38Z",
  "region": "us-east-1",
  "resources": [
    "arn:aws:swf:us-east-1:444455556666:/domain/SimpleWorkflowUserSimulator"
  ],
  "detail": {
    "eventId": 11,
    "eventType": "WorkflowExecutionFailed",
    "workflowExecutionDetail": {
      "executionInfo": {
        "execution": {
          "workflowId": "1234-5678-9012",
          "runId": "777788889999"
        },
        "workflowType": {
          "name": "SimpleWorkflowUserSimulator",
          "version": "myWorkflow"
        },
        "startTimestamp": 1588953158481,
        "closeTimestamp": 1588953458560,
        "executionStatus": "CLOSED",
        "closeStatus": "FAILED",
        "parent": null,
        "parentExecutionArn": null,
        "tagList": null,
        "cancelRequested": false
      },
      "executionConfiguration": {
        "taskStartToCloseTimeout": "60",
        "executionStartToCloseTimeout": "1000",
        "taskList": {
          "name": "1111-1111-1111"
        },
        "taskPriority": null,
        "childPolicy": "ABANDON",
        "lambdaRole": "arn:aws:iam::444455556666:role/BasicSWFLambdaExecution"
      },
      "openCounts": {
        "openActivityTasks": 0,
        "openDecisionTasks": 0,
        "openTimers": 0,
        "openChildWorkflowExecutions": 0,
        "openLambdaFunctions": 0
      },
      "latestActivityTaskTimestamp": null,
    }
  }
}
```

### A execução atingiu o tempo limite
<a name="ev-events-execution-timed-out"></a>

```
{
  "version": "0",
  "id": "1111-2222-3333",
  "detail-type": "Simple Workflow Execution State Change",
  "source": "aws.swf",
  "account": "444455556666",
  "time": "2020-05-05T17:26:30Z",
  "region": "us-east-1",
  "resources": [
    "arn:aws:swf:us-east-1:444455556666:/domain/SimpleWorkflowUserSimulator"
  ],
  "detail": {
    "eventId": 6,
    "eventType": "WorkflowExecutionTimedOut",
    "workflowExecutionDetail": {
      "executionInfo": {
        "execution": {
          "workflowId": "1234-5678-9012",
          "runId": "777788889999"
        },
        "workflowType": {
          "name": "SimpleWorkflowUserSimulator",
          "version": "myWorkflow"
        },
        "startTimestamp": 1588698073748,
        "closeTimestamp": 1588699590745,
        "executionStatus": "CLOSED",
        "closeStatus": "TIMED_OUT",
        "parent": null,
        "parentExecutionArn": null,
        "tagList": null,
        "cancelRequested": false
      },
      "executionConfiguration": {
        "taskStartToCloseTimeout": "60",
        "executionStartToCloseTimeout": "1000",
        "taskList": {
          "name": "1111-1111-1111"
        },
        "taskPriority": null,
        "childPolicy": "ABANDON",
        "lambdaRole": "arn:aws:iam::444455556666:role/BasicSWFLambdaExecution"
      },
      "openCounts": {
        "openActivityTasks": 1,
        "openDecisionTasks": 0,
        "openTimers": 0,
        "openChildWorkflowExecutions": 0,
        "openLambdaFunctions": 0
      },
      "latestActivityTaskTimestamp": 1588699585802,
    }
  }
}
```

### Execução encerrada
<a name="ev-events-execution-aborted"></a>



```
{
  "version": "0",
  "id": "1111-2222-3333",
  "detail-type": "Simple Workflow Execution State Change",
  "source": "aws.swf",
  "account": "444455556666",
  "time": "2020-05-08T22:37:26Z",
  "region": "us-east-1",
  "resources": [
    "arn:aws:swf:us-east-1:444455556666:/domain/canary"
  ],
  "detail": {
    "eventId": 48,
    "eventType": "WorkflowExecutionTerminated",
    "workflowExecutionDetail": {
      "executionInfo": {
        "execution": {
          "workflowId": "1234-5678-9012",
          "runId": "777788889999"
        },
        "workflowType": {
          "name": "1111-1111-1111",
          "version": "1.3"
        },
        "startTimestamp": 1588977445279,
        "closeTimestamp": 1588977446062,
        "executionStatus": "CLOSED",
        "closeStatus": "TERMINATED",
        "parent": null,
        "parentExecutionArn": null,
        "tagList": null,
        "cancelRequested": false
      },
      "executionConfiguration": {
        "taskStartToCloseTimeout": "60",
        "executionStartToCloseTimeout": "120",
        "taskList": {
          "name": "1111-1111-1111-2222-2222-2222"
        },
        "taskPriority": null,
        "childPolicy": "TERMINATE",
        "lambdaRole": null
      },
      "openCounts": {
        "openActivityTasks": 0,
        "openDecisionTasks": 1,
        "openTimers": 0,
        "openChildWorkflowExecutions": 0,
        "openLambdaFunctions": 0
      },
      "latestActivityTaskTimestamp": 1588977445882,
    }
  }
}
```