

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# EventBridge untuk perubahan status eksekusi Amazon SWF
<a name="ev-events"></a>

Anda menggunakan Amazon EventBridge untuk menanggapi perubahan status atau peristiwa dalam AWS sumber daya. Ketika Amazon SWF memancarkan suatu acara, itu selalu masuk ke bus EventBridge acara default untuk akun Anda. Anda dapat membuat aturan untuk acara, mengaitkannya dengan bus acara default, dan menentukan tindakan target yang akan diambil saat EventBridge menerima acara yang cocok dengan aturan. Dengan cara ini, Anda dapat memantau alur kerja tanpa harus terus melakukan polling menggunakan API [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_GetWorkflowExecutionHistory.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_GetWorkflowExecutionHistory.html). Berdasarkan perubahan dalam eksekusi alur kerja, Anda dapat menggunakan EventBridge target untuk memanggil AWS Lambda fungsi, mempublikasikan pesan ke topik Amazon Simple Notification Service (Amazon SNS), dan banyak lagi.

Anda dapat melihat konten penuh dari kejadian perubahan status eksekusi menggunakan [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DescribeWorkflowExecution.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DescribeWorkflowExecution.html).

Untuk informasi selengkapnya, lihat [Panduan EventBridge Pengguna Amazon](https://docs.aws.amazon.com/eventbridge/latest/userguide/). 

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

Tipe kejadian riwayat berisi perubahan state eksekusi. Bagian `detail` dari setiap kejadian berisi setidaknya parameter berikut:
+ `eventId`: ID acara yang ditunjukkan oleh GetWorkflowExecutionHistory.
+ `workflowExecutionDetail`: state alur kerja saat kejadian dipancarkan.
+ `eventType`: tipe kejadian riwayat, salah satu dari berikut ini:
  + `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`

## Contoh kejadian Amazon SWF
<a name="ev-events-events"></a>

Berikut ini adalah contoh Amazon SWF mengirim acara ke: EventBridge 

**Topics**
+ [Eksekusi dimulai](#ev-events-execution-started)
+ [Eksekusi selesai](#ev-events-execution-completed)
+ [Eksekusi gagal](#ev-events-execution-failed)
+ [Batas waktu eksekusi habis](#ev-events-execution-timed-out)
+ [Eksekusi diakhiri](#ev-events-execution-aborted)

Dalam setiap kasus, bagian `detail` dalam data kejadian menyediakan informasi yang sama sebagai API [https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DescribeWorkflowExecution.html](https://docs.aws.amazon.com/amazonswf/latest/apireference/API_DescribeWorkflowExecution.html). Bidang `executionStatus` menunjukkan status eksekusi pada saat kejadian dikirim, baik `OPEN` atau `CLOSED`. 

### Eksekusi dimulai
<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,
    }
  }
}
```

### Eksekusi selesai
<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,
    }
  }
}
```

### Eksekusi gagal
<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,
    }
  }
}
```

### Batas waktu eksekusi habis
<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,
    }
  }
}
```

### Eksekusi diakhiri
<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,
    }
  }
}
```